Java 更改TabHost+;像真正的键盘一样格式化按钮| | Android
好的。。首先,我是Eclipse新手,Android开发新手,Java 我必须制作一个VoIP应用程序,我设置了一些选项卡(是的,文本混乱): 这是我的XML代码Java 更改TabHost+;像真正的键盘一样格式化按钮| | Android,java,android,xml,eclipse,android-tabhost,Java,Android,Xml,Eclipse,Android Tabhost,好的。。首先,我是Eclipse新手,Android开发新手,Java 我必须制作一个VoIP应用程序,我设置了一些选项卡(是的,文本混乱): 这是我的XML代码 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent"
<?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" >
<TabHost
android:id="@+id/tabhost"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TabWidget
android:id="@android:id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</TabWidget>
<FrameLayout
android:id="@android:id/tabcontent"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:orientation="horizontal"
android:id="@+id/Recents"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Recents">
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:id="@+id/Keypad"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Keypad" >
<Button
android:id="@+id/bNumber1"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1" />
<Button
android:id="@+id/bNumber2"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2" />
<Button
android:id="@+id/bNumber3"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3" />
<Button
android:id="@+id/bNumber4"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4" />
<Button
android:id="@+id/bNumber5"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5" />
<Button
android:id="@+id/bNumber6"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6" />
<Button
android:id="@+id/bNumber7"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7" />
<Button
android:id="@+id/bNumber8"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8" />
<Button
android:id="@+id/bNumber9"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9" />
<Button
android:id="@+id/bNumber0"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0" />
<Button
android:id="@+id/bCall"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="Call" />
<Button
android:id="@+id/bSMS"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="SMS" />
<Button
android:id="@+id/bClear"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="C" />
<TextView
android:id="@+id/etNumberField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
>
</TextView>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:id="@+id/Sms"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="SMS">
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:id="@+id/Ratings"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Ratings">
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:id="@+id/Account"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="Account">
</LinearLayout>
</FrameLayout>
</LinearLayout>
</TabHost>
</LinearLayout>
现在,我的问题是,我必须定位所有的“数字”按钮(1、2、3、4等等),使它们看起来像一个真正的键盘
我的问题是,我真的无法在图形布局上“看到”它是如何定位的
我也无法从内存中对按钮进行编码,因为我还是新手。
有没有人能帮我把代码格式化成键盘一样的格式
或者甚至给我一个解决方案,在我编写代码时,我如何看到定位
提前感谢,
帕拉蒙 好吧,经过一些研究,我已经弄明白了 如果有人在编写代码时想知道如何更改选项卡视图,并且能够看到它的样子- 只需创建一个.XML文件,并按照您希望的选项卡外观进行设计。 在此解决方案之前,我必须编辑选项卡视图,查看以下内容: 稍后,您需要在线性布局中输入
(“recents”是.XML布局名称)
我的看起来像这样:
<LinearLayout
android:id="@+id/Keypad"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:text="Keypad">
<include layout="@layout/keypad" />
//"keypad" is the name of the .xml file.
</LinearLayout>
//“keypad”是.xml文件的名称。
这就是你“改变”观点的方式 另外,由于我是Android开发新手,我想知道如何格式化我的键盘,使它们看起来像一个合法的键盘 多亏了include代码,我可以在编码和设计时看到选项卡 截图: 我所做的: -将所有按钮分为三组。 因此,1线性布局将覆盖按钮1、2和3 另一个将覆盖4、5和6(以此类推) -在线性布局上放置砝码 这有助于我将它们“推”到底部 我知道这可能不是正确或最安全的方法,但只要它有效,我就很满意 XML代码:
<?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="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="5"
android:paddingTop="10dp" >
<TextView
android:id="@+id/etNumberField"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ellipsize="end"
android:ems="100"
android:singleLine="true"
android:textSize="23dp" />
<Button
android:id="@+id/bContact"
style="?android:attr/buttonStyleSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0"
android:padding="10dp"
android:text="Contact" />
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:padding="1dp">
<Button
android:id="@+id/bNumber1"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="1"
android:padding="10dp" />
<Button
android:id="@+id/bNumber2"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="2"
android:padding="10dp"/>
<Button
android:id="@+id/bNumber3"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="3"
android:padding="10dp" />
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:padding="1dp">
<Button
android:id="@+id/bNumber4"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="4" />
<Button
android:id="@+id/bNumber5"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="5" />
<Button
android:id="@+id/bNumber6"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="6" />
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:padding="1dp">
<Button
android:id="@+id/bNumber7"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="7" />
<Button
android:id="@+id/bNumber8"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="8" />
<Button
android:id="@+id/bNumber9"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="9" />
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="0"
android:padding="1dp">
<Button
android:id="@+id/bNumberStar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="*" />
<Button
android:id="@+id/bNumber0"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="0" />
<Button
android:id="@+id/bNumberHash"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="#" />
</LinearLayout>
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:padding="1dp">
<Button
android:id="@+id/bSMS"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="SMS" />
<Button
android:id="@+id/bCall"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Call"
android:textColor="#00FF00"
/>
<Button
android:id="@+id/bClear"
android:layout_weight="1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="C"
/>
</LinearLayout>
</LinearLayout>
如果您对这个解决方案有任何疑问,或者我可以如何帮助您,请随时在下面发表评论 如果你想设计一个安卓用户界面,你必须做你的家庭作业。了解TableLayout——它使生成按钮的矩形网格变得“容易”。还有谷歌“安卓布局教程”。你会发现很多有趣和有用的链接。@DaleWilson虽然这不完全是我想要的,但它确实帮助了我。行!具有具有按钮的列的gridview。