android-如何在相对布局内部居中放置表格

android-如何在相对布局内部居中放置表格,第1张

概述我有一个表格布局,每行包含两个编辑文本和一个微调器,我想将其放置在相对布局的中央,但无法绕开它.<?xmlversion="1.0"encoding="utf-8"?><RelativeLayoutandroid:id="@+id/Relative_4"xmlns:android="http://schemas.android.com/apkes/android"androi

我有一个表格布局,每行包含两个编辑文本和一个微调器,
我想将其放置在相对布局的中央,但无法绕开它.
@H_502_3@

@H_502_3@

    <?xml version="1.0" enCoding="utf-8"?><relativeLayout androID:ID="@+ID/relative_4"xmlns:androID="http://schemas.androID.com/apk/res/androID"androID:layout_wIDth="fill_parent"androID:layout_height="fill_parent"><ImageVIEw    androID:ID="@+ID/imageVIEw1"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:layout_alignParenttop="true"    androID:layout_centerHorizontal="true"    androID:layout_marginBottom="5dp"    androID:layout_margintop="5dp"    androID:src="@drawable/SomePhoto" /><tableLayout     androID:layout_centerHorizontal="true"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:layout_gravity="center_horizontal"    androID:layout_margintop="40dp"    androID:clickable="false"    androID:duplicateParentState="false"    androID:focusable="false"    androID:layoutDirection="rtl"    androID:focusableIntouchMode="false"    androID:longClickable="false"    androID:gravity="center_horizontal"    androID:orIEntation="vertical" ><tableRow    androID:ID="@+ID/tableRow1"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:baselineAligned="true" >    <EditText        androID:ID="@+ID/editText_4_1"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:clickable="false"        androID:duplicateParentState="false"        androID:ems="5"        androID:focusable="false"        androID:focusableIntouchMode="false"        androID:freezesText="false"        androID:gravity="center_vertical|center_horizontal"        androID:inputType="none"        androID:longClickable="false"        androID:scrollHorizontally="false"        androID:text="Course"        androID:textAllCaps="false" >        <requestFocus />    </EditText>    <EditText        androID:ID="@+ID/editText_4_2"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:clickable="false"        androID:duplicateParentState="false"        androID:ems="6"        androID:focusable="false"        androID:focusableIntouchMode="false"        androID:gravity="center_vertical|center_horizontal"        androID:inputType="none"        androID:longClickable="false"        androID:text="credit hours"        androID:layout_centerHorizontal="true" />    <EditText        androID:ID="@+ID/editText_4_3"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:clickable="false"        androID:duplicateParentState="false"        androID:ems="4"        androID:focusable="false"        androID:focusableIntouchMode="false"        androID:gravity="center_vertical|center_horizontal"        androID:inputType="none"        androID:longClickable="false"        androID:text="Grades" /></tableRow><ScrollVIEw    androID:ID="@+ID/scrollVIEw1"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:layout_weight="24.67" >    <tableLayout        androID:layout_wIDth="match_parent"        androID:layout_height="match_parent"        androID:orIEntation="vertical" ><tableRow    androID:ID="@+ID/tableRow2"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content" >    <EditText        androID:ID="@+ID/editText_4_4"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:ems="4"        androID:gravity="center_vertical|center_horizontal"        androID:hint="course_1"        androID:maxlines="1" />    <EditText        androID:ID="@+ID/editText_4_5"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"        androID:ems="6"        androID:gravity="center_vertical|center_horizontal"        androID:inputType="number"        androID:text="0" />    <Spinner        androID:ID="@+ID/spinner_4_1"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"/></tableRow><relativeLayout    androID:ID="@+ID/tableRow13"    androID:layout_wIDth="wrap_content"    androID:layout_height="wrap_content"    androID:baselineAligned="true" >    <relativeLayout        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content" >        <button            androID:background="@drawable/resetBtn"            androID:ID="@+ID/button_4_1"            androID:layout_marginleft="70dp"            androID:layout_wIDth="wrap_content"            androID:layout_height="wrap_content"            />         <button        androID:background="@drawable/Cal@R_403_6603@teBtn"        androID:ID="@+ID/button_4_2"        androID:layout_toRightOf="@+ID/button_4_1"        androID:layout_marginleft="90dp"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"         />    </relativeLayout></relativeLayout></tableLayout></ScrollVIEw><com.mopub.mobileads.MoPubVIEwandroID:ID="@+ID/advIEw"androID:layout_wIDth="fill_parent"androID:layout_height="50dp"androID:layout_alignParentBottom="true"/></tableLayout></relativeLayout>

任何有关如何解决此问题的帮助将不胜感激.
谢谢@H_502_3@

解决方法:@H_502_3@

对您的xml代码进行这些更改.我希望它可以工作@H_502_3@

@H_502_3@

 <relativeLayout     androID:ID="@+ID/relative_4"    xmlns:androID="http://schemas.androID.com/apk/res/androID"    androID:layout_wIDth="fill_parent"    androID:layout_height="fill_parent"    androID:gravity="center" //This is new line    >    <tableLayout         androID:layout_centerHorizontal="true"        androID:layout_wIDth="wrap_content"        androID:layout_height="wrap_content"         androID:layout_centerInParent="true"//This is new line              androID:clickable="false"        androID:focusable="false"        androID:layoutDirection="rtl"        androID:focusableIntouchMode="false"        androID:longClickable="false"        androID:gravity="center_horizontal"        androID:orIEntation="vertical" >
总结

以上是内存溢出为你收集整理的android-如何在相对布局内部居中放置表格全部内容,希望文章能够帮你解决android-如何在相对布局内部居中放置表格所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1078328.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-27
下一篇2022-05-27

发表评论

登录后才能评论

评论列表(0条)

    保存