2016-03-18 7 views
1

enter image description hereAndroidの緑色の円イメージを配置する方法は?

私は、黒と黄色の2つの異なるレイアウト(線形レイアウト)を相対レイアウトで並べています。イメージに示されているように緑色の円のイメージを配置する必要があります。これを行う最善の方法は何ですか?

+0

これまでに何をしようとしていますか?私たちにあなたのXMLレイアウトのコードを教えてください – ProblemSlover

+0

私はそれをJavaコードで管理することを考えています。実行時に私はブラックレイアウトの高さを得て、実行時に緑のイメージを配置します。 xmlで管理することはできません。 – user3586231

+0

この緑色の円のビューは何ですか? – Mohit

答えて

1

あなたの黒いレイアウトのコピーをお互いに使って、黒の上から下の黒まで新しいレイアウトを作成することです。そしてあなたのイメージをこのレイアウトの中心に置きます。例えば

:あなたはこのような何かを行うことができ

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

    <View 
     android:id="@+id/black_top" 
     android:layout_width="match_parent" 
     android:layout_height="150dp" 
     android:background="@color/black" /> 

    <View 
     android:id="@+id/black_top_invisible_copy" 
     android:layout_width="match_parent" 
     android:layout_height="150dp" 
     android:layout_below="@id/black_top" 
     android:visibility="invisible" /> 

    <View 
     android:id="@+id/yellow_bot" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@id/black_top" 
     android:background="@color/black" /> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_alignBottom="@id/black_top_invisible_copy" 
     android:layout_alignTop="@id/black_top" 
     android:gravity="center"> 

     <ImageView 
      android:layout_width="50dp" 
      android:layout_height="50dp" 
      android:src="@drawable/circle" /> 

    </LinearLayout> 

</RelativeLayout> 
1

<layer-list xmlns:android="http://schemas.android.com/apk/res/android" > 
    <item android:drawable="@color/black" android:top="dimension"/> 
    <item android:drawable="@color/yelllow" android:bottom="dimension"/> 

</layer-list> 

このドロアブルを使用して、使用しているレイアウトの背景として設定します。あなたがバックグラウンドで得る色の間に緑色の円のイメージを維持しようとします。

関連する問題