Tôi có 2 file xml như thế này:động tải tập tin XML để LinearLayout
main.xml:
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:id="@+id/ll"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:orientation="horizontal">
</LinearLayout>
</HorizontalScrollView>
items.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/rl"
android:layout_width="100dp"
android:layout_height="100dp">
<ImageView
android:id="@+id/img"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginLeft="15dp"
android:layout_marginTop="15dp"
android:contentDescription="@string/app_name"
android:gravity="center"
android:src="@drawable/icon_shop2" />
<TextView
android:id="@+id/providerName"
style="@style/WhiteTextMedium"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/img"
android:layout_gravity="bottom"
android:paddingLeft="10dp"
android:text="Example" />
</RelativeLayout>
main.xml được sử dụng cho MainActivity. Câu hỏi của tôi là cách tải động 3 bố cục items.xml vào Linearlayout trong HorizontalScrollView
của main.xml!
Làm tăng bố cục mục và thêm từng mục một theo chiều ngang của bạn Xem ... –
Bạn có thể cho tôi mã nguồn cho đến giờ ...! –
@HT Không, tôi không ... Tôi chỉ cung cấp cho bạn một ý tưởng ... Bây giờ thực hiện tìm kiếm trên Google .... bạn sẽ nhận được mã ..... –