0
我正在繪製一個圖層列表... 我想設置描邊(2dp,顏色:#000000),角落(5dp),背景(黃色)和添加圖像在右側,但我無法更改圖像大小。android如何更改背景xml中的大小圖像
,但我有類似的東西:
這是我的代碼: content_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="info.e_konkursy.myapplication.MainActivity"
tools:showIn="@layout/app_bar_main">
<TableLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TableRow
android:layout_width="200dp"
android:layout_height="20dp"
android:background="@drawable/bg_tablerow11"
android:padding="10dp">
<TextView
android:id="@+id/textView2"
android:layout_width="100dp"
android:text="@string/country"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textView3"
android:layout_width="150dp"
android:layout_height="20dp"
android:text="Poland"
android:textAppearance="?android:attr/textAppearanceMedium" />
</TableRow>
</TableLayout>
</RelativeLayout>
bg_tablerow11.xml :
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:layout_width="10dp"
android:layout_height="10dp"
android:drawable="@drawable/arrow"
android:gravity="right" />
<item>
<shape
android:padding="10dp"
android:shape="rectangle">
<stroke
android:width="2dp"
android:color="#000000" />
<corners
android:bottomLeftRadius="5dp"
android:bottomRightRadius="5dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
</shape>
</item>
</layer-list>
感謝您的幫助。
我可以看到你複製s ame xml兩次。 'bg_tablerow11.xml'與'content_main.xml'相同 –
我很抱歉,我的錯誤,現在沒關係。 – Pionas
國名可以更改。默認值是僅查看文本「Country:」和背景圖像。我實現了setOnClickListener,然後添加國名 – Pionas