Có thể tạo nút có bố cục xml tùy chỉnh không?Nút có bố cục XML tùy chỉnh
Tôi có bố trí này:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="1dp"
android:background="#7e7e7e">
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:background="#f9f9f9">
<TextView
android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:text="ButtText"
android:textColor="#000000">
</TextView>
<ImageView
android:id="@+id/ImageView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/arrow"
android:layout_alignParentRight="true">
</ImageView>
</RelativeLayout>
</LinearLayout>
Bây giờ tôi muốn sử dụng này trên một nút. Bất cứ ai biết làm thế nào tôi có thể làm điều này?
Tôi đã suy nghĩ nếu tôi có tệp Button.java mở rộng Nút. Và sau đó setView (R.layout.mylayout.xml); ... nhưng đó là dễ dàng, và nó rõ ràng không làm việc
Trân Martin
mọi thứ đều dễ dàng như vậy. Cảm ơn u cho thông tin của ngày hôm nay! :) – f0rz