2017-03-28 24 views
0

私は単純なレイアウトの4 TextViewがあります。そのうち2つはテキストであらかじめ入力されており、数字は1から3までです。他の2つは、ユーザのタップであるListItemに基づいて埋められます。彼らはテキストの異なる長さで満たされているので、大部分の時間は、テキストが重なります。上記のテキストビューにユーザーが入力した内容に基づいて、テキストビューの位置を変更するにはどうすればよいですか?

テキストが重なっていると、3番と4番の位置を画面上でさらに下に移動するにはどうすればよいですか?

コードは、以下に添付されています。それは構造のように思える

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
android:orientation="vertical" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:layout_below="@+id/imageView2" 
android:layout_centerHorizontal="true"> 

    <ImageView 
     android:id="@+id/bildeAvGjenstand" 
     android:layout_width="150dp" 
     android:layout_height="150dp" 
     android:contentDescription="@string/bildeBesk" 
     android:layout_marginBottom="133dp" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" /> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="THIS IS PREFILLED" 
     android:textSize="35sp" 
     android:layout_above="@+id/gjenstand" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 

    <TextView 
     android:id="@+id/gjenstand" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text=""      
     android:textSize="30sp" 
     android:visibility="visible" 
     android:layout_above="@+id/bildeAvGjenstand" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_marginBottom="24dp" /> 

    <TextView 
     android:id="@+id/gjoremaal" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="30sp" 
     android:text="" <!-- I want this text view to change position --> 
     android:visibility="visible" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_below="@+id/textView3" /> 

<TextView 
    android:id="@+id/textView3" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentLeft="true" <!-- I want this text view to change position --> 
    android:layout_alignParentStart="true" 
    android:layout_alignParentTop="true" 
    android:text="THIS IS PREFILLED" 
    android:textSize="35sp" /> 

+0

重複すると、どういう意味ですか? – JediBurrell

+0

ユーザーが特定のリストアイテムをタップしたときに入力されるテキストが、あらかじめ入力されたテキストを上書きするため、テキストが判読できなくなることを意味します。 –

答えて

0

は少し奇妙です。あなたがしようとしていることの最終目標が何であるか分かりませんが、私は考えがあると思います。上記のテキストのサイズに基づいて以下の項目を調整するコードをここに書き直しました。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:layout_below="@+id/imageView2" 
    android:layout_centerHorizontal="true"> 

    <TextView 
     android:id="@+id/textView3" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_alignParentTop="true" 
     android:text="THIS IS PREFILLED" 
     android:textSize="35sp" 
     /> 

    <TextView 
     android:id="@+id/gjoremaal" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textSize="30sp" 
     android:text="This text changes " 
     android:visibility="visible" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_below="@+id/textView3" 
     android:layout_marginBottom="200dp" 
     /> 


    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="THIS IS PREFILLED" 
     android:textSize="35sp" 
     android:layout_below="@+id/gjoremaal" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" /> 

    <TextView 
     android:id="@+id/gjenstand" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="This text changes" 
     android:textSize="30sp" 
     android:visibility="visible" 
     android:layout_below="@+id/textView2" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true" 
     android:layout_marginBottom="24dp" /> 

    <ImageView 
     android:id="@+id/bildeAvGjenstand" 
     android:layout_width="150dp" 
     android:layout_height="150dp" 
     android:contentDescription="sample" 
     android:layout_below="@+id/gjenstand" 
     android:layout_centerHorizontal="true" /> 
    </RelativeLayout> 
+0

彼はダイナミックになると思う。 – JediBurrell

関連する問題