如何解决如何使android:background显示在侧面而不是完整视图
当我发现我在使用View和LinearLayout只是为了使矢量背景在特定位置(toStartof TextView)可见时,我正在优化我的应用程序。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="300dp"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="300dp"
android:layout_height="50dp"
android:orientation="Horizontal">
<View
android:id="@+id/locationButton"
android:layout_width="50dp"
android:layout_height="match_parent"
android:background="@drawable/ic_baseline_location_on_24" />
<TextView
android:id="@+id/om_address_change"
android:layout_width="250dp"
android:layout_height="50dp"
android:text="change" />
</LinearLayout>
</LinearLayout>
这样,我使用了额外的LinearLayout和View。我想知道是否还有其他实现此目标的最佳方法。就像在TextView中声明某些属性,以使其强制背景开始一样。
这是ic_baseline_location_on_24.xml
<vector android:height="24dp" android:tint="#D3D1D1"
android:viewportHeight="24" android:viewportWidth="24"
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="@android:color/white" android:pathData="M12,2C8.13,2 5,5.13 5,9c0,5.25 7,13 7,13s7,-7.75 7,-13c0,-3.87 -3.13,-7 -7,-7zM12,11.5c-1.38,0 -2.5,-1.12 -2.5,-2.5s1.12,-2.5 2.5,1.12 2.5,2.5 -1.12,2.5 -2.5,2.5z"/>
</vector>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。