【发布时间】:2020-07-09 18:12:35
【问题描述】:
这是我的第一个 android 应用程序,我面临很多问题。我想做这样的设计:
我尝试了很多解决方案,但没有任何效果。 这是我的代码:
<TableLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<View
android:layout_height="2dip"
android:background="@color/dark_blue"/>
<!--Product information-->
<TableRow android:id="@+id/product_info">
<ImageView android:id="@+id/product_img"
android:src="@drawable/mdpi_product_verify_scan_code"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<TextView android:id="@+id/tvdesc"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:text="description description description "
android:textColor="@color/black"
/>
</TableRow>
<View
android:layout_height="2dip"
android:background="@color/dark_blue"/>
<!--Images button-->
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Product Description"
android:textColor="@color/black"
android:textAppearance="?android:textAppearanceMedium"
/>
<FrameLayout
android:background="@color/dark_blue"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="top|left"
android:padding="5dp">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/mdpi_btn_show_images_icon"
android:background="@android:color/transparent"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Images"/>
</FrameLayout>
</TableRow>
<TableRow android:id="@+id/product_info">
<ImageView android:id="@+id/ima"
android:src="@drawable/mdpi_product_verify_scan_code"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1"
/>
<TextView android:id="@+id/tv2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="2"
android:text="description description description "
android:textColor="@color/black"
/>
</TableRow>
<!--Verification -->
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="product verification"
android:textAppearance="?android:textAppearanceMedium"
android:textColor="@color/green"/>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="This product can be verified. Tap on the VERIFY PRODUCT button above."
android:textColor="@color/green"/>
</TableRow>
</TableLayout>
这就是结果
如你所见,所有元素都搞砸了 当我设置重力时,图像按钮也会消失
这张图片显示了哪些问题:
- 如何将每个文本放在一行中。
- 将图像设置在左侧(重力左侧不起作用)
- 如何画垂直线?
- 如何将图像与文本放在一起?(我使用的是跨度,但它只适用于一行,我有两个文本行,是否有合并两个垂直单元格)。
- 图片按钮消失。
感谢您的帮助。
【问题讨论】:
-
您尝试替换 TableLayout 了吗?也许是RelativeLayout 和LinearLayouts/something 的某种组合?
-
@Keyser 实际上没有,我仍然不知道所有的 android 设计技术。我看到了一些使用 tablelayout 的教程,这就是我使用它的原因。
-
然后和其他人一起做实验。 Android Dev 网站上有很多示例和文档
-
@Keyser 我会的,谢谢你的帮助 :)
标签: android android-tablelayout