【发布时间】:2018-04-08 15:30:24
【问题描述】:
我正在尝试为我的 Android 应用程序创建一个布局,我想在其中显示图像,每个图像的宽度应为 50%,高度为 50%,到目前为止,我如何实现这一点,我构建了以下内容:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="test.com.tests.MainActivity"
tools:showIn="@layout/app_bar_main">
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:stretchColumns="1">
<TableRow>
<!-- Column 1 -->
<ImageButton
android:id="@+id/tbl_txt1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_margin="4dip"
android:layout_weight="1"
android:background="@color/red"
android:padding="10dip"
android:text="Column 1"
android:textColor="@color/white" />
<!-- Column 2 -->
<ImageButton
android:id="@+id/tbl_txt2"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:layout_margin="4dip"
android:layout_weight="1"
android:background="@color/red"
android:padding="10dip"
android:text="Column 2"
android:textColor="@color/white" />
</TableRow>
</TableLayout>
</android.support.constraint.ConstraintLayout>
类似这样的: https://ibb.co/c2Gngc
【问题讨论】:
-
发布预期的输出图像。
-
@Abhi 像这样我的绘画技巧很烂ibb.co/c2Gngc
标签: android android-layout android-xml