2012-04-27 10 views
1

私は最初のスクリーンショットとしてレイアウトを作りたいと思います。 needアンドロイドに配置/オーバーラップ(z-インデックス)

、私が実行しようとしましたが、それは私がどのように我々は他の上にあるビューを配置することができます知ってほしい私のレイアウト

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:gravity="center" 
    android:orientation="vertical" 
    android:padding="20dip" > 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="0dip" 
     android:layout_weight="1" 
     android:background="@color/red" 
     android:orientation="vertical" 
     android:paddingBottom="40dip" 
     android:paddingLeft="10dip" 
     android:paddingRight="10dip" 
     android:paddingTop="10dip" > 

     <LinearLayout 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@color/black" 
      android:gravity="center_vertical" > 

      <ScrollView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:layout_marginLeft="-20dip" > 

       <TextView 
        android:id="@+id/textView1" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_gravity="center" 
        android:gravity="center" 
        android:text="lololo" /> 
      </ScrollView> 

      <ImageView 
       android:id="@+id/lady" 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:src="@drawable/temp" /> 
     </LinearLayout> 
    </LinearLayout> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="-20dip" 
     android:gravity="center" > 


     <Button 
      android:id="@+id/button1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@drawable/button_left" 
      android:text="next" /> 

     <Button 
      android:id="@+id/button2" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="@drawable/button_right" 
      android:text="prev" /> 
    </LinearLayout> 

</LinearLayout> 

ここで第二のスクリーンショットのように have

を判明変化するz-インデックスを持つ? Zインデックスを変えて、あるビューを他のビューの上に配置するにはどうすればいいですか? Zインデックスを変えて、あるビューを他のビューの上に配置するにはどうすればいいですか?

+0

あなたはScrollViewの親を変更しようとしたとのLinearLayoutからでframeLayout –

+0

にImageViewのはい、それは私がいけない – silentnuke

+0

は、z順序はあなたのレイアウトを見れば、私は何を考えてあなたを助けると思って助けにはならなかったがありますあなたが行っているのは、あなたの内側の線形レイアウトでtextviewを作成したことです.zオーダーを設定すると、それは他の兄弟と前になりますが、私はあなたがそれを望んでいないと思っています。私はあなたのtextviewを線形レイアウトまたはその親...私はあなたが相対的なレイアウトですべてを変更する必要があると思ういくつかのダミーのビューと決済でうまくいくでしょう。 –

答えて

1

RelativeLayourを使用して、レイアウトを再設計....

あなたが望むようあなたが完璧な結果を得るでしょう。..

RelativeLayourは、あなたがこの簡単... ​​

+0

私は相対レイアウトを使用しようとしましたが、必要な結果が得られませんでした。より詳細なことができますか? – silentnuke

2

使用のようなので、ものにできるようにRelativeLayout

あなたはこの例を使用することができます。

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="200dp" 
    android:layout_height="200dp" 
    android:orientation="vertical" 
    android:padding="10dp" > 

    <RelativeLayout 
     android:layout_width="fill_parent" 
     android:layout_height="fill_parent" > 

     <!-- Bottom layer --> 
     <LinearLayout 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:layout_margin="20dp" 
      android:background="#DDDDDD" > 

      <!-- Other views --> 
     </LinearLayout> 

     <!-- Top layer --> 
     <LinearLayout 
      android:layout_width="50dp" 
      android:layout_height="50dp" 
      android:layout_alignParentLeft="true" 
      android:layout_alignParentTop="true" 
      android:background="#F0AB00" > 

      <!-- Other views --> 
     </LinearLayout> 
    </RelativeLayout> 

</LinearLayout> 

そしてそれは次のようになります。

enter image description here

あなたが写真で見ることができるように、小さな四角形が大きい(灰色の上方に配置されます)長方形。これは、ビューをRelativeLayoutに次々に追加することによって(その間を参照することなく)発生する可能性があります。

よろしく

+0

私は相対レイアウトについて知っていますが、問題は解決しません。 – silentnuke

+0

正確に何を達成しようとしているのか説明できますか?意味、ScrollViewの目的は何ですか? 'lololo'のテキストと画像は、画面上で静的であるべきか、それともスクロール可能なビュー内にあるべきですか? – sromku

関連する問題