Những gì tôi muốn đạt được cũng giống như cách bố trí này: Làm cách nào để đạt được giao diện người dùng Android như bố cục hình ảnh này? Về android: clipChildren
tôi đã cố gắng sử dụng mã này, để đạt được như hình ảnh đó, nhưng không may, tôi đã thất bại. Đây là đoạn mã của tôi:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:clipChildren="false"
>
<RelativeLayout
android:id="@+id/text_area_third"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/round_corner_background"
android:focusable="false"
android:paddingBottom="5dp"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:paddingTop="5dp" >
<TextView
android:id="@+id/text_download_purch_third"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignRight="@+id/acron_icon"
android:layout_marginLeft="5dp"
android:layout_marginRight="30dp"
android:layout_marginTop="10dp"
android:gravity="left"
android:maxLines="2"
android:text="1asdasdasdasdadsasdasdadasdasdasdasdasdasdasdasd"
android:textColor="@color/black"
android:textSize="10sp"
android:textStyle="normal" />
<ImageView
android:id="@+id/acron_icon"
android:layout_width="20dp"
android:layout_height="20dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_margin="5dp"
android:layout_marginTop="10dp"
android:background="@drawable/acron"
android:scaleType="fitCenter" />
</RelativeLayout>
<LinearLayout
android:layout_alignTop="@+id/text_area_third"
android:layout_alignLeft="@+id/text_area_third"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/orange"
android:layout_marginLeft="-10dp"
android:layout_marginTop="-10dp"
android:padding="3dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="GET"
android:textColor="@color/white"
android:textSize="13sp"
android:textStyle="bold" />
</LinearLayout>
</RelativeLayout>
Bạn có thể thấy rằng, các "GET" nhãn (với nền màu cam) được cắt bớt thông qua phụ huynh bị ràng buộc. Tôi đã thiết lập android:clipChildren="false"
, nhưng nó vẫn bị cắt bớt. Ai đó có thể giúp tôi được không?
gì sẽ xảy ra nếu bạn sắp xếp nó vào bố trí cha mẹ (sử dụng 'layout_alignParentTop/Left') thay vì' text_area_third' (Và điều chỉnh 'layout_marginLeft/Top' cho phù hợp)? – Geobits
@Geobits: tôi cũng đã thử điều đó, nhưng lỗi tương tự đã xảy ra –