2017-10-08 20 views
1

내 앱에는 현재 온도 및 날씨 설명을 표시하는 경고 대화 상자의 두 가지 텍스트보기가 있습니다. 이 문제는 설명이 변경 될 때마다 정렬이 변경된다는 점입니다.Android Studio에서 내 텍스트를 올바르게 정렬하려면 어떻게해야합니까?

내 레이아웃을 상대 레이아웃으로 사용하고 다른 레이아웃에 따라 둘 중 하나를 사용하여 이동하려고했지만이 방법으로는 도움이되지 않습니다. 어떤 제안?

이 내 현재 코드 : 그것은 데이터가 당신이 wrap_content를 사용할 때 데이터를 감싸 증가 할 때, 데이터 크기 변화에 따른 일어나고

<?xml version="1.0" encoding="utf-8"?> 
<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:orientation="vertical"> 


    <TextView 
     android:id="@+id/climaText" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentTop="true" 
     android:layout_alignStart="@+id/desc" 
     android:layout_marginTop="18dp" 
     android:layout_marginStart="120dp" 
     android:textColor="@android:color/white" /> 

    <TextView 
     android:id="@+id/desc" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_below="@+id/climaText" 
     android:layout_centerHorizontal="true" 
     android:layout_marginTop="13dp" 
     android:textColor="@android:color/white" /> 



</RelativeLayout> 

답변

0

. 부모보기를 사용하여 높이를 수정하는 것이 좋습니다. 코드가 있는지, 작동하는지 알려주세요. 감사합니다

<?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="wrap_content" 
     android:layout_height="250px"> 

     <TextView 
      android:id="@+id/climaText" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentTop="true" 
      android:layout_alignStart="@+id/desc" 
      android:layout_marginStart="120dp" 
      android:layout_marginTop="18dp" 
      android:textColor="@android:color/white" /> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="250px"> 

     <TextView 
      android:id="@+id/desc" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_below="@+id/climaText" 
      android:layout_centerHorizontal="true" 
      android:layout_marginTop="13dp" 
      android:textColor="@android:color/white" /> 

    </LinearLayout> 

</LinearLayout> 
+0

죄송합니다.이 기능이 작동하지 않았습니다. –