2012-03-21 1 views
0

私は3つのTextViewを持つ相対レイアウトを使用しています。次に、画面の下部に相対的に、4つのボタンの設定のようなコンパスがあり、その上の1つに対して、その上に3つのボタンがあり、EditTextと別のボタンがその上にあります。Androidのインターフェイス - TextViewsをScrollboxに制限する

enter image description here

私は3 TextViewsはまだお互いの上に積み重ねることがしたいが、私は彼らがのEditTextの先頭に、インターフェイスの上部から延びスクロールボックスになりたいです。しかし、私はAndroid用のXMLでこれをどうやって行うのか分かりません。誰にも何か提案や、役に立つチュートリアルへのリンクがありますか?

編集:私のXML:

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/relativeLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/background" > 


    <Button 
     android:id="@+id/turnS" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:text="Turn S" /> 

    <Button 
     android:id="@+id/turnW" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/turnS" 
     android:layout_toLeftOf="@id/turnS" 
     android:text="Turn W" /> 

    <Button 
     android:id="@+id/turnE" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/turnS" 
     android:layout_toRightOf="@id/turnS" 
     android:text="Turn E" /> 

    <Button 
     android:id="@+id/turnN" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/turnW" 
     android:layout_centerHorizontal="true" 
     android:text="Turn N" /> 

    <Button 
     android:id="@+id/lookB" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentRight="true" 
     android:layout_above="@id/turnN" 
     android:text="  Look  " /> 

    <Button 
     android:id="@+id/takeB" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/turnN" 
     android:layout_centerHorizontal="true" 
     android:text="  Take " /> 

    <Button 
     android:id="@+id/useB" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_above="@id/turnN" 
     android:text="  Use  " /> 

    <Button 
     android:id="@+id/Enter" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/useB" 
     android:layout_alignParentRight="true" 
     android:layout_alignTop="@+id/edittext" /> 


    <TextView 
     android:id="@+id/lookView" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:textColor="#FFA500" 

     android:text="@string/hello" /> 

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:textColor="#FFFF00" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@id/lookView" 
     android:text="@string/hello" /> 

    <TextView 
     android:id="@+id/textView2" 
     android:layout_width="fill_parent" 
     android:textColor="#00FF00" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_below="@id/textView1" 
     android:text="@string/hello" /> 


    <EditText 
     android:id="@+id/edittext" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_above="@id/lookB" 
     android:layout_toLeftOf="@+id/Enter" > 

     <requestFocus /> 
    </EditText> 

</RelativeLayout> 

どうもありがとう、 Zeldarulah

+0

ない明らかに、あなたはこれで何を意味するかを教えてくださいすることができます」私は3つのTextViewsを重ね合わせてもらいたいですが、それらをスクロールボックスに入れて、インターフェイスの上から伸ばしてください " – Triode

+0

私はすべてのボタンとtを必要とします彼は彼らがどこに残っているために下部に入力しますが、私はオーバーフローするテキストが編集ボックスの上で停止し、それを見ることができるように上下にスクロールすることができます。 – Zeldarulah

+0

ここにxmlファイルを投稿してください、ありがとう – Triode

答えて

1

このレイアウトしてみてください。

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/relativeLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="@drawable/background" > 

    <Button 
     android:id="@+id/turnS" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_alignParentBottom="true" 
     android:layout_centerHorizontal="true" 
     android:text="Turn S" /> 

    <Button 
     android:id="@+id/turnW" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/turnS" 
     android:layout_toLeftOf="@id/turnS" 
     android:text="Turn W" /> 

    <Button 
     android:id="@+id/turnE" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/turnS" 
     android:layout_toRightOf="@id/turnS" 
     android:text="Turn E" /> 

    <Button 
     android:id="@+id/turnN" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/turnW" 
     android:layout_centerHorizontal="true" 
     android:text="Turn N" /> 

    <Button 
     android:id="@+id/lookB" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/turnN" 
     android:layout_alignParentRight="true" 
     android:text="  Look  " /> 

    <Button 
     android:id="@+id/takeB" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/turnN" 
     android:layout_centerHorizontal="true" 
     android:text="  Take " /> 

    <Button 
     android:id="@+id/useB" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/turnN" 
     android:layout_alignParentLeft="true" 
     android:text="  Use  " /> 

    <Button 
     android:id="@+id/Enter" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/useB" 
     android:layout_alignParentRight="true" 
     android:layout_alignTop="@+id/edittext" /> 

    <EditText 
     android:id="@+id/edittext" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_above="@id/lookB" 
     android:layout_alignParentLeft="true" 
     android:layout_toLeftOf="@+id/Enter" /> 

    <ScrollView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_above="@id/edittext" > 

     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:orientation="vertical" > 

      <TextView 
       android:id="@+id/lookView" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content"     
       android:text="@string/hello" 
       android:textColor="#FFA500" /> 

      <TextView 
       android:id="@+id/textView1" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content"     
       android:text="@string/hello" 
       android:textColor="#FFFF00" /> 

      <TextView 
       android:id="@+id/textView2" 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content"     
       android:text="@string/hello" 
       android:textColor="#00FF00" /> 
     </LinearLayout> 
    </ScrollView> 

</RelativeLayout> 
+0

私はこれを学校で取り組んできました。そのため、月曜日までテストするチャンスはありませんが、このScrollView + LinearLayoutの組み合わせはまさに私がやったと思ったものでしたので、私はそれを期待しています働く(私は金曜日にScrollViewについて知り、Linearで使用しなければならないことを学んだが、時間がなくなった。) ありがとう、私はできるだけ早くそれを試してみる。 :) – Zeldarulah

+0

@ Zeldarulah 'LinearLayout'の代わりに' View'を使うことができます。 'ScrollView'はそれがただ一つの子しか持たないことを要求しています。 – Luksprog

+0

@Zeldarulah私はあなたが何をしようとしているのか、おそらく写真(またはより良い説明)を理解していませんか? – Luksprog

関連する問題