2016-04-18 194 views
0

这看起来像我的Android设计有问题。这里的问题是:Textview响应边距/填充

Here is the image

正如你所看到的, “HTTP:// LABEL 2 GOES HERE” 是正确的标签1文本的顶部:“这仅仅是标签1测试.. .....“我怎么能这样做,以便”http:// LABEL 2 GOES HERE“将永远在”标签1“30dp以下,无论它有多长或多短?

我怎样才能让这个

这里是我的XML文件:

<?xml version="1.0" encoding="utf-8"?> 
<ScrollView xmlns:tools="http://schemas.android.com/tools" 
    android:layout_height="match_parent" 
    android:layout_width="match_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android" 

    <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" 
     android:paddingBottom="@dimen/activity_vertical_margin" 
     android:paddingLeft="@dimen/activity_horizontal_margin" 
     android:paddingRight="@dimen/activity_horizontal_margin" 
     android:paddingTop="@dimen/activity_vertical_margin" 
     android:minHeight="1000dp"> 

     <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:text="About:" 
     android:id="@+id/about" 
     android:textSize="16dp" 
     android:layout_marginTop="30dp" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 

     <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:id="@+id/label1" 
     android:textSize="16dp"/> 

     <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:text="Website:" 
     android:id="@+id/website" 
     android:textSize="16dp" 
     android:layout_marginTop="30dp" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 

     <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:id="@+id/label2" 
     android:textSize="16dp" 
     android:autoLink="web"/> 

    </RelativeLayout> 
</ScrollView> 
+1

您可以包括XML,你已经为这一点。 – buczek

+0

@buczek我刚刚用XML代码编辑了OP。 – johnny880

回答

0

你想打好下面的实际说明一切。这是我做的事情,应该为你工作。

enter image description here

增加的大小

enter image description here

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:android="http://schemas.android.com/apk/res/android"> 

    <TextView 
     android:id="@+id/about" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="About:"/> 


    <TextView 
     android:id="@+id/aboutDescription" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@id/about" 
     android:text="Description \n description"/> 

    <TextView 
     android:id="@+id/website" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Website:" 
     android:layout_below="@id/aboutDescription" 
     /> 

    <TextView 
     android:id="@+id/websiteDescription" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@id/website" 
     android:layout_below="@id/aboutDescription" 
     android:text="Description \n description"/> 

</RelativeLayout> 
+0

我刚刚用XML代码编辑了OP。 – johnny880

0

这里是你正在寻找

什么父母取的线性布局和不同的线2个不同的相对布局(不必要)

相对布局有高度包装内容,因此它会根据您的数据大小而增加。

enter image description here

这里是代码:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical"> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <TextView 
     android:id="@+id/about" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="About :" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textSize="16dp" /> 

    <TextView 
     android:id="@+id/label1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/about" 
     android:text="This is just a test for lebel 1 \nThis is just a test for lebel 1 \nThis is just a test for lebel 1 \nThis is just a test for lebel 1" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textSize="16dp" /> 
</RelativeLayout> 

<RelativeLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content"> 

    <TextView 
     android:id="@+id/website" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="Website :" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textSize="16dp" /> 

    <TextView 
     android:id="@+id/label2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_toRightOf="@+id/website" 
     android:minLines="4" 
     android:text="This is just a test for lebel 2 \nThis is just a test for lebel 2 \nThis is just a test for lebel 2 \nThis is just a test for lebel 2 \nThis is just a test for lebel 2" 
     android:textAppearance="?android:attr/textAppearanceMedium" 
     android:textSize="16dp" /> 
</RelativeLayout></LinearLayout>