Android一些小的技能點~ 1.含有EditText的佈局進入,不彈出軟鍵盤 2.解決ScrollView底部有佈局,不能滑動的問題 3.Android中自定義checkbox樣式

1.含有EditText的佈局進入,不彈出軟鍵盤

在佈局的父控件添加屬性:

android:focusable="true"
android:focusableInTouchMode="true"

實例:

<RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:focusable="true"
            android:focusableInTouchMode="true"
            android:gravity="center_vertical">
        <EditText
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:hint="搜索"/>
    </RelativeLayout>

2.解決ScrollView底部有佈局,不能滑動的問題

並在ScrollView中添加屬性 android:layout_above="@id/linear",linear是底部的佈局的名稱,這樣就能滑動了。

3.Android中自定義checkbox樣式

1.首先在drawable文件夾中添加drawable文件checkbox_style.xml。
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
 
    <item android:drawable="@drawable/checkbox_pressed" android:state_checked="true"/>
    <item android:drawable="@drawable/checkbox_normal" android:state_checked="false"/>
    <item android:drawable="@drawable/checkbox_normal"/>
 
</selector>
2.在values文件夾下的styles.xml文件中添加CustomCheckboxTheme樣式。
<style name="CustomCheckboxTheme" parent="@android:style/Widget.CompoundButton.CheckBox">
	<item name="android:button">@drawable/checkbox_style</item>
</style>

3.在佈局文件中使用CustomCheckboxTheme樣式。
<CheckBox
        android:id="@+id/cb"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        style="@style/CustomCheckboxTheme" />

都是我遇到的一些小改動,查詢的別人的csdn,然後總結了一下下~


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章