2016-04-28 10 views
0

カレンダーの一部として、1日ビューとイベントビューの2つのビューがあります。幅のある日のビューを埋めるイベントが必要ですが、同じ位置/時間に別のイベントを追加すると、それらのイベントの幅を分割したいと思っています...私はJavaを使ってイベントを動的に追加しています。ビューが重ならないように使用できる属性はありますか?ビューを相対レイアウトで水平に重ねて表示しない

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

</RelativeLayout> 

<?xml version="1.0" encoding="utf-8"?> 
<ie.test.calendar.CalendarEventView 
xmlns:android="http://schemas.android.com/apk/res/android" 
android:orientation="horizontal" 
android:id="@+id/eventView" 
android:background="@drawable/event_view" 
android:layout_width="match_parent" 
android:layout_height="wrap_content"> 

    <TextView xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/eventTextView" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingTop="3dp" 
    android:paddingBottom="5dp" 
    android:paddingLeft="5dp" 
    android:paddingRight="3dp" 
    android:textAppearance="@android:style/TextAppearance.Medium" 
    android:textColor="@android:color/white"/> 

</ie.test.calendar.CalendarEventView> 

答えて

0

私はあなたが水平方向の親ビューとしてライニアレイアウトを使用する必要があると思います。また、幅の重みの概念も使用します。それはあなたがIDを使用して、実行時にルールを設定することができ​​

上を見てみましょう子量

0

に応じて、あなたの親ビューをdevideます。

layoutparams.addRule(RelativeLayout.ALIGN_RIGHT, R.id.id1) 

LinearLayoutを使用すると、はるかに簡単だろうと、私は考える、けれども。

+0

私は最初のイベントを挿入するときに、同じ位置に追加される予定のイベントがあることを知る必要がありますか?そして、それのためのスペースを作る? – ovg

関連する問題