我正在尝试使复选框变小。我曾尝试过使用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