android - Issue positionning customLinear Layout -
android - Issue positionning customLinear Layout -
i've created custom linear layout in order have "square" layout fitting width of parent i'm having problem positioning linearlayout. want linearlayout
below squarelinearlayout
, got (both layout top aligned):
i've tried android:parentalignbottom="true"
, android:gravity="bottom"
nil works me ...
here layout xml :
<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context="com.dekajoo.rpg.mainactivity" > <com.dekajoo.rpg.custom_layouts.squarelinearlayout android:id="@+id/game_layout" android:layout_width="match_parent" android:layout_height="match_parent" android:gravity="center" android:orientation="vertical" android:background="#f00" /> <android:linearlayout android:id="@+id/control_bar" android:layout_width="match_parent" android:layout_height="100dip" android:background="#0f0" android:gravity="center" android:orientation="horizontal" /> </relativelayout>
and here squarelinearlayout class :
package com.dekajoo.rpg.custom_layouts; import android.content.context; import android.util.attributeset; import android.widget.linearlayout; public class squarelinearlayout extends linearlayout { public squarelinearlayout(context context) { super(context); } public squarelinearlayout(context context, attributeset attrs) { super(context, attrs); } /*public squareview(context context, attributeset attrs, int defstyle) { super(context, attrs, defstyle); }*/ @override public void onmeasure(int widthmeasurespec, int heightmeasurespec) { super.onmeasure(widthmeasurespec, heightmeasurespec); int width = measurespec.getsize(widthmeasurespec); int height = measurespec.getsize(heightmeasurespec); int size = width > height ? height : width; setmeasureddimension(size, size); } }
thanks,
add linearlayout
, android:layout_below="@id/game_layout"
android android-layout
Comments
Post a Comment