DJ-*_*DOO 4 android include horizontal-scrolling android-layout android-viewpager
我的布局如下:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<ImageView
android:id="@+id/logo_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/logos_background">
</ImageView>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="5dp"
android:layout_alignBottom="@+id/logo_background"
>
<TextView
android:id="@+id/logoDetails"
android:text="Test Logo details"
android:textSize="15sp"
android:layout_centerHorizontal="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
<TextView
android:id="@+id/stockQuantity"
android:layout_centerHorizontal="true"
android:textSize="20sp"
android:layout_below="@+id/logoDetails"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="x10"/>
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我需要在另一个布局中多次包含此布局,我已完成如下操作:
<HorizontalScrollView
android:layout_below = "@+id/selectLayout"
android:id="@+id/pager"
android:scrollbars="none"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="horizontal"
android:layout_marginTop="20dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<include layout="@layout/viewpager_item_layout"/>
<include layout="@layout/viewpager_item_layout"/>
<include layout="@layout/viewpager_item_layout"/>
<include layout="@layout/viewpager_item_layout"/>
<include layout="@layout/viewpager_item_layout"/>
<include layout="@layout/viewpager_item_layout"/>
<include layout="@layout/viewpager_item_layout"/>
</LinearLayout>
</HorizontalScrollView>
Run Code Online (Sandbox Code Playgroud)
这给出了以下结果:

问题是我需要访问每个文本视图和图像视图<include>.所以徽标图像会有所不同,测试徽标的详细信息会有所不同,每个版本的'x10'会有所不同,因为我希望从数据库中填充它们.任何人都可以对此发光吗?
我打算使用一个视图寻呼机,但这不起作用,因为它占用了屏幕的整个宽度和高度.
<include android:id="@+id/news_title"
layout="@layout/viewpager_item_layout"/>
Run Code Online (Sandbox Code Playgroud)
试试它是否有帮助.
你可以像这样访问:
View includedLayout = findViewById(R.id.news_title);
TextView insideTheIncludedLayout = (TextView )includedLayout.findViewById(R.id.logoDetails);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1743 次 |
| 最近记录: |