我正在嘗試使複選框變小。我曾嘗試過使用XML中的佈局和Java中的.width()/。height。也沒有辦法改變它的大小。我參加了向其他人推薦的教程,他問了這個問題,但我不明白他做了什麼。有什麼建議麼?在android中更改複選框的大小
4
A
回答
3
從另一個question這裏SO:
你只需要設置相關的可繪製並設置他們中的複選框:
<CheckBox
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="new checkbox"
android:background="@drawable/my_checkbox_background"
android:button="@drawable/my_checkbox" />
關鍵是如何設置可繪製的。 Here's a good tutorial about this。
編輯:只是爲了使它有點更清晰,你將需要這些文件,以使教程工作:
CheckBoxTestActivity.java:
import android.app.Activity;
import android.os.Bundle;
public class CheckBoxTestActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
的main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<CheckBox
android:id="@+id/checkBox1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Checked CheckBox"
android:checked="true"/>
<CheckBox
android:id="@+id/checkBox2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Unchecked CheckBox" />
<CheckBox
android:id="@+id/checkBox3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/checkbox_background"
android:button="@drawable/checkbox"
android:text="New Checked CheckBox"
android:checked="true"/>
<CheckBox
android:id="@+id/checkBox4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/checkbox_background"
android:button="@drawable/checkbox"
android:text="New Unchecked CheckBox" />
</LinearLayout>
checkbox.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:state_checked="false"
android:drawable="@drawable/checkbox_off_background"/>
<item
android:state_checked="true"
android:drawable="@drawable/checkbox_on_background"/>
</selector>
checkbox_background.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="@drawable/btn_check_label_background" />
</selector>
和btn_check_label_background.9.png,從教程頁面checkbox_off_background.png和checkbox_on_background.png。
1
相關問題
- 1. 更改android複選框的大小
- 2. 更改Xamarin Android複選框的大小
- 3. 更改Flex中複選框的大小
- 4. 更改複選框的文本大小
- 5. 更改Android 2.0中的複選框大小
- 6. 更改複選框的大小及其中的複選標記
- 7. 更改複選框大小WPF
- 8. 使用CSS複選框大小更改
- 9. 如何更改android複選框的按鈕大小?
- 10. 如何在複選框中更改按鈕的大小
- 11. 如何使用Android複選框更改列表項大小?
- 12. 更改複選框大小android不使用XML
- 13. 閃亮的複選框組框的更改大小
- 14. Android更改複選框選中顏色
- 15. 如何更改DatagridviewCheckboxCell中的複選框大小
- 16. 更改ColorPicker對話框的大小android
- 17. 自定義複選框正在更改大小
- 18. 自定義複選框會在isChecked爲true時更改其大小Android?
- 19. Android調整大小複選框
- 20. 增加複選框大小 - Phonegap Android
- 21. 更改自定義CSS複選框的大小
- 22. 如何更改複選框的文字大小
- 23. 複選框在yii2中調整大小
- 24. 複選框大小在IE7中變化
- 25. 更改大小:Android單選按鈕
- 26. Android將複選框首選項的值從另一個複選框中更改
- 27. 更改複選框
- 28. 更改Android-Seekbar的大小?
- 29. 複選框調整大小
- 30. 複選框大小增加
你能一點點更具體?你想要多少? – Brian 2012-01-09 01:53:27
在Facebook上記住您的用戶名和密碼的複選框的大小 – Aaron 2012-01-09 01:59:25
可能重複的[Android:如何更改CheckBox大小?](http://stackoverflow.com/questions/2151241/android-how-to-change-checkbox大小) – Christoph 2012-10-26 13:00:51