[英]Linearlayout with rounded corners and image resource background?
這樣的事情可能嗎?
我在嘗試:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" >
<item>
<bitmap android:src="@drawable/smoke_bg" />
</item>
<item>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="10dp"
android:shape="rectangle" >
<corners
android:bottomLeftRadius="15dp"
android:bottomRightRadius="15dp"
android:topLeftRadius="15dp"
android:topRightRadius="15dp" />
</shape>
</item>
並將其設置為我的線性布局背景,但它仍然無法正常工作。 我只得到一個矩形。
您可以使用這些代碼:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/border" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/list_selector"
android:orientation="horizontal" >
<RelativeLayout
android:id="@+id/thumbnail"
android:layout_width="72dip"
android:layout_height="72dip"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="5sp"
android:layout_marginRight="5dip"
android:layout_marginTop="5sp"
android:background="@drawable/border_image" >
<ImageView
android:id="@+id/list_image"
android:layout_width="70dip"
android:layout_height="70dip"
android:layout_centerInParent="true"
android:layout_marginTop="5sp"
android:paddingBottom="2sp"
android:paddingLeft="2sp"
android:paddingRight="2sp" />
</RelativeLayout>
<!-- Title Of Song -->
<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/thumbnail"
android:layout_marginRight="5sp"
android:layout_toLeftOf="@+id/thumbnail"
android:text="title"
android:textColor="#040404"
android:textSize="16sp"
android:textStyle="bold" />
<!-- Artist Name -->
<cTextView
android:id="@+id/producid"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title"
android:layout_marginRight="5sp"
android:layout_marginTop="1dip"
android:layout_toLeftOf="@+id/thumbnail"
android:gravity="right"
android:text="Just gona stand there and ..."
android:textColor="#343434"
android:textSize="12dip" />
<TextView
android:id="@+id/categoriid"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone" />
</RelativeLayout>
</RelativeLayout>
和 Border.xml :
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" >
<stroke
android:width="2dip"
android:color="#979797" />
<padding
android:left="1sp"
android:right="1sp"
android:top="1sp" />
<corners android:radius="1dip" />
</shape>
像這樣嘗試:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:padding="0dp"
android:shape="rectangle" >
<stroke
android:width="0dp"
android:color="#000000" />
<solid android:color="#fbc9c3" />
<corners android:radius="14dp" />
</shape>
更改以下內容以增加/減少拐角:
<corners android:radius="14dp" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.