Android 文本视图左右对齐的水平布局
我有以下视图结构:Android 文本视图左右对齐的水平布局,android,android-layout,Android,Android Layout,我有以下视图结构: ------------------------------------ ||------------||------------------|| ||Text View 1 || Long Text View 3|| ||------------||------------------|| ||------------||------------------|| ||Text 2 || View 4 || ||------------||--
------------------------------------
||------------||------------------||
||Text View 1 || Long Text View 3||
||------------||------------------||
||------------||------------------||
||Text 2 || View 4 ||
||------------||------------------||
------------------------------------
我想要以下行为:
此代码正在为您运行
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<RelativeLayout
android:id="@+id/Sperator"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/FirstLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_toLeftOf="@id/Sperator" >
<TextView
android:id="@+id/tvFirstLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="TextView"
android:textSize="24sp" />
<TextView
android:id="@+id/tvFirstParagraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/tvFirstLabel"
android:text="ASFDNASKLCFNLASKFKLACNKJCUKENFIWOCNAMSKLDJAIUEFBN" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/SecondLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/Sperator" >
<TextView
android:id="@+id/tvSecondLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="YourLongTextView"
android:textSize="24sp" />
<TextView
android:id="@+id/tvSecondParagraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/tvSecondLabel"
android:text="ASFDNASKLsdfnjsacjsbnfsbfjhsbfjdsbfjhsbvfjhsbvfjbskCFNLASKFKLACNKJCUKENFIWOCNAMSKLDJAIUEFBN" />
</RelativeLayout>
截图是
这里是润农。。请试试这个
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<RelativeLayout
android:id="@+id/FirstLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:minWidth="100dp" >
<TextView
android:id="@+id/tvFirstLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="TextView"
android:textSize="24sp" />
<TextView
android:id="@+id/tvFirstParagraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/tvFirstLabel"
android:text="fasfdsfsdfsdcvzxfasd" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/Sperator"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/FirstLayout" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/SecondLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/Sperator"
android:minWidth="100dp" >
<TextView
android:id="@+id/tvSecondLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="YourLongTextView"
android:textSize="24sp" />
<TextView
android:id="@+id/tvSecondParagraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/tvSecondLabel"
android:text="ASFDNASKLsdfnjsacjsbnfsbfjhsbfjdsbfjhsbvfjhsbvfjbskCFNLASKFKLACNKJCUKENFIWOCNAMSKLDJAIUEFBN" />
</RelativeLayout>
</RelativeLayout>
我希望这对您有所帮助:)好的,下面的代码对我很有用。如果您想让面板宽度增加50%以上,请将android:layout\u width=“0dp”替换为两个相对长度的
android:layout\u width=“wrap\u content”
发布你的xaml,这样我们就有了一个起点。我认为阿卜杜勒·卡迪尔·努卡勒姆(Abdulkadir NURKALEM)有一个很好的方法。如果一个专栏很短,它会让另一个专栏增长50%以上吗?但你给了我这个想法。它看起来像以下结构:RelativeLayout(RelativeLayout(LinearLayout(TextView,TextView)),RelativeLayout(LinearLayout(TextView,TextView)))应该做这项工作如果这个答案对你有帮助,请检查这个答案:)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity" >
<RelativeLayout
android:id="@+id/FirstLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:minWidth="100dp" >
<TextView
android:id="@+id/tvFirstLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="TextView"
android:textSize="24sp" />
<TextView
android:id="@+id/tvFirstParagraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/tvFirstLabel"
android:text="fasfdsfsdfsdcvzxfasd" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/Sperator"
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/FirstLayout" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/SecondLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_toRightOf="@id/Sperator"
android:minWidth="100dp" >
<TextView
android:id="@+id/tvSecondLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="YourLongTextView"
android:textSize="24sp" />
<TextView
android:id="@+id/tvSecondParagraph"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@id/tvSecondLabel"
android:text="ASFDNASKLsdfnjsacjsbnfsbfjhsbfjdsbfjhsbvfjhsbvfjbskCFNLASKFKLACNKJCUKENFIWOCNAMSKLDJAIUEFBN" />
</RelativeLayout>
</RelativeLayout>