2016-04-18 6 views
0

私のAndroidデザインに問題があるようです。ここで問題がある:Textviewレスポンスマージン/パディング

Here is the image

あなたが見ることができるように、「のhttp:// LABEL 2をここには、」ラベル1文字の上に右である:「これはラベル1のためだけのテストです。.. ..... "どのように長くても短くても、" http:// LABEL 2 GOES HERE "が常に" label 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

を使用すると、ルート要素と使用アンドロイドとして相対的なレイアウトを持っていることを確認してください:ラベルにあなたの最後のラベルのlayout_below IDを2. android:layout_marginTopをラベル2に追加してください。あなたはうまくいくはずです。あなたは、実際の説明の下にすべてを置くしたい

http://developer.android.com/guide/topics/ui/layout/relative.html http://developer.android.com/reference/android/view/ViewGroup.MarginLayoutParams.html

+0

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>