0
我有造型customview的问题。 我想在不同的布局中使用不同的样式。但我的风格不适用。CustomView造型
CustomView布局:
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
<ImageView
android:id="@+id/img"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:id="@+id/txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
</merge>
在另一个布局定义:
<com.buka.customviews.Bukaview
android:id="@+id/bukaId"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="@style/BukaStyle1">
styles.xml
<style name="BukaStyle1">
<item name="android:textSize">10sp</item>
</style>
<style name="BukaStyle2">
<item name="android:textSize">20sp</item>
</style>
由于
仍然不起作用。我认为问题在于我在TextView上定义了BukaStyleTextSize,但是在BukaView上应用了样式。有任何想法吗? – Hoochwo
我也这么认为。你能否将BukaView的属性传递给java类中的TextView?为什么不使用带有drawableLeft或drawableTop的TextView? – yDelouis
其实我有更复杂的布局,我需要设置像大小/颜色和其他许多参数TextView中。我无法从代码中的attr中设置样式。 – Hoochwo