我在Android中使用layer-list xml自定义我的布局。但是,我完成了图层列表并确切地查看了我想要自定义的内容。但是,当我在我的布局中应用时,它显示的不是我想要的,我不知道为什么。请帮助我! 这是我的layer-list.xml:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<size
android:width="@dimen/dp35"
android:height="@dimen/dp35" />
<solid android:color="@color/colorAccent" />
</shape>
</item>
<item android:right="12dp"
android:top="@dimen/dp20"
android:bottom="-5dp">
<rotate
android:fromDegrees="25">
<shape android:shape="rectangle">
<solid android:color="@color/colorAccent" />
</shape>
</rotate>
</item>
<item android:left="12.5dp"
android:top="@dimen/dp20"
android:bottom="-5dp">
<rotate
android:fromDegrees="-25">
<shape android:shape="rectangle">
<solid android:color="@color/colorAccent" />
</shape>
</rotate>
</item>
我使用layer-list.xml的布局
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="100dp"
android:layout_height="100dp"
android:background="@drawable/bg_sale_off"
android:text="Textview"
android:layout_centerInParent="true" />
</RelativeLayout>
答案 0 :(得分:0)
你可以尝试
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_sale_off"
android:text="Textview"
android:layout_centerInParent="true" />
</RelativeLayout>