Leo*_*Leo 189 android textview android-layout android-linearlayout compound-drawables
根据我的代码运行新的Lint工具.它提出了很多好的建议,但这个我无法理解.
此标签及其子代可以替换为一个和复合drawable
问题:检查当前节点是否可以使用复合drawables替换为TextView.
包含ImageView和TextView的LinearLayout可以作为复合drawable更有效地处理
这是我的布局
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_centerInParent="true">
<ImageView
android:id="@+id/upImage"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_gravity="center_vertical"
android:scaleType="centerInside"
android:src="@drawable/up_count_big">
</ImageView>
<TextView
android:id="@+id/LikeCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="2dp"
android:layout_marginBottom="1dp"
android:textColor="@color/gray"
android:textSize="16sp"
android:layout_gravity="center_vertical">
</TextView>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
在这种情况下,有人能提供一个如何制作复合可绘制的具体例子吗?
chi*_*uki 253
TextView 附带4个复合抽屉,左,上,右,下各一个.
在你的情况,你不需要LinearLayout和ImageView根本.只需添加android:drawableLeft="@drawable/up_count_big"到您的TextView.
有关详细信息,请参阅TextView #setCompoundDrawablesWithIntrinsicBounds.
Jav*_*r P 20
如果由于某种原因你需要通过代码添加,你可以使用这个:
mTextView.setCompoundDrawablesWithIntrinsicBounds(left, top, right, bottom);
Run Code Online (Sandbox Code Playgroud)
左侧,顶部,右侧底部是Drawables
| 归档时间: |
|
| 查看次数: |
99481 次 |
| 最近记录: |