2012-04-05 14 views
0

私のアプリがページ間をスライドできるように水平方向にスクロールできるようにします。しかし、AndroidのSDKでこの機能を使用すると、xmlレイアウトを親にすることができません。つまり、ボタンとオブジェクトを含むフルスクリーンを表示できません。Horizo​​ntalScrollViewの使い方は?

この問題を解決するにはどうすればよいですか、それとも別の方法ですか?

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

    <RelativeLayout 
     android:layout_width="348dp" 
     android:layout_height="559dp" > 

     <ImageButton 
      android:id="@+id/imageButton1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentLeft="true" 
      android:layout_marginBottom="341dp" 
      android:layout_marginLeft="146dp" 
      android:src="@drawable/ic_launcher" /> 

    </RelativeLayout> 


</HorizontalScrollView> 
+0

あなたのコードstackoverflow.com/の –

+0

はい、ここで私が追加されたコード^^ – user1144349

+0

が重複する可能性を追加することができればそれはいいだろう質問/ 5565949 –

答えて

0

変更のLinearLayoutに対するレイアウト:

は、ここでは、コードです。垂直ScrollViewと同様に、LinearLayoutを使用します。ここで

は、私は私のプロジェクトの一つで持っているのサンプルレイアウトです:

<HorizontalScrollView 
      android:id="@+id/horizontalScrollView1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:scrollbars="none" > 

      <LinearLayout 
       android:id="@+id/LinearLayout1" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:orientation="horizontal" > 

       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/class_tab" /> 

       <Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/exam" /> 

       <Button 
        android:id="@+id/button_more" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:text="@string/more" /> 

      </LinearLayout> 
     </HorizontalScrollView> 
+0

クールですが、ボタンやすべてのレイアウト属性はどこにありますか? – user1144349

+0

ああ、私はそれらをスタイル属性に追加しました。私はそれを変更させてください。 –

+0

クール!これはどのように機能しますか?私はそれをテストする場合、正確に何が起こったのですか? – user1144349

関連する問題