我正在研究一個應用程序,並且我在主菜單上有一系列按鈕,我希望它們都具有相同的文本大小。我可以在屬性文件中指定它嗎?是否可以在XML中動態設置Android按鈕文本大小?
這是我目前的XML文件。
<?xml version="1.0" encoding="utf-8"?>
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/sensors_available"
android:text="@string/sensors_available"
android:textSize="12sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/b_start_hm"
android:text="@string/hm_start_service"
android:textSize="12sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/b_stop_hm_service"
android:text="@string/hm_stop_service"
android:textSize="12sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
<TableRow
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<Button
android:id="@+id/b_start_hot_video"
android:text="@string/video_service_start"
android:onClick="startHotVideoService"
android:textSize="12sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/b_hv_stop_service"
android:text="@string/hv_stop_service"
android:textSize="12sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</TableRow>
</TableLayout>
是否有可能對我來說,替換所有12sp
喜歡的東西@string\custom_text_size
,然後定義在string.xml文件?當我嘗試這個時,我開始我的應用程序時遇到了一個致命異常。
u可以使用捫... 看到更多此處獲得更多信息 http://stackoverflow.com/questions/11121028/load-dimension-value-from-res-values-dimension-xml-from-source-code –