如何创建按钮的网格下面一个TextView [英] How can i create a grid of buttons with a textview below
本文介绍了如何创建按钮的网格下面一个TextView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个屏幕像我上面绘制(试图)。
A,B,C,D,E,F,G和H 按钮
,p是一个的EditText
。
I want to create a screen like I've (tried to) drawn above.
A,b,c,d,e,f,g and h are buttons
, and p is a EditText
.
现在我想要做到的是,部署一个更大或更小的屏幕上时,或旋转,会发生以下情况:
Now what I want to accomplish is that when deployed on a larger or smaller screen, or rotated, the following will happen:
- 元素'P'保持相同的高度,但水平尺寸(被
更宽/小) - 元素的-H(按钮)的所有尺寸和水平
垂直。因此,当屏幕变得两倍宽,按钮
两次更宽,并且当它的两倍高,按钮的两倍
那么高。
我已经能够创建一个按钮排水平大小(以 lineairlayout
和的android:layout_weight
,但我没有得到任何进一步的。
I've been able to create one row of buttons to size horizontally (with a lineairlayout
and a android:layout_weight
, but I am not getting any further.
推荐答案
试试吧,希望它的工作原理:
Try it out,hope it works:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal" >
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
</LinearLayout>
<EditText
android:layout_width="match_parent"
android:layout_height="50dp" />
</LinearLayout>
这篇关于如何创建按钮的网格下面一个TextView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文