xml - Android GUI: Layout manager -
xml - Android GUI: Layout manager -
i'm learning layout managers improve app design. part worked out ok. thing want buttons positioned little higher.i can accomplish removing 3 buttons layout manager doing have issues on lower res devices. (the buttons position on edittext fields or position on advertisement @ bottom). i've tried things found online ended ruining layout.
here xml file:
<?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" android:layout_width="fill_parent" android:layout_height="fill_parent"> <linearlayout android:id="@+id/linearlayout3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal"> <linearlayout android:id="@+id/textviewlayoutleft" android:layout_width="wrap_content" android:layout_height="match_parent" android:orientation="vertical"> <textview android:id="@+id/tvppl" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingbottom="10dp" android:paddingleft="10dp" android:paddingright="10dp" android:paddingtop="20dp" android:text="price per liter" android:textstyle="bold" /> <textview android:id="@+id/tvavgconsumption" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingbottom="10dp" android:paddingleft="10dp" android:paddingright="10dp" android:paddingtop="10dp" android:text="avg(l/100km)" android:textstyle="bold" /> <textview android:id="@+id/tvdistance" android:layout_width="wrap_content" android:layout_height="wrap_content" android:padding="10dp" android:text="distance (km)" android:textstyle="bold" /> <textview android:id="@+id/tvamountofpersons" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingbottom="10dp" android:paddingleft="10dp" android:paddingright="10dp" android:paddingtop="10dp" android:text="# persons" android:textstyle="bold" /> <textview android:id="@+id/textview5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingleft="10dp" android:paddingright="10dp" android:paddingtop="20dp" android:text="price per person" android:textstyle="bold" /> </linearlayout> <linearlayout android:id="@+id/textfieldlayoutright" android:layout_width="166dp" android:layout_height="wrap_content" android:orientation="vertical"> <edittext android:id="@+id/textprijsperliter" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputtype="numberdecimal" /> <edittext android:id="@+id/textverbruik" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:ems="10" android:inputtype="numberdecimal" /> <edittext android:id="@+id/textafstand" android:layout_width="match_parent" android:layout_height="wrap_content" android:ems="10" android:inputtype="numberdecimal" /> <edittext android:id="@+id/textaantalpersonen" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:ems="10" android:imeoptions="actiongo" android:inputtype="numberdecimal" /> <textview android:id="@+id/textviewppp" android:layout_width="wrap_content" android:layout_height="wrap_content" android:paddingleft="10dp" android:paddingtop="20dp" android:textappearance="?android:attr/textappearancelarge" android:textcolor="#ffff000f" android:textstyle="bold" /> </linearlayout> </linearlayout> <linearlayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparentbottom="true" android:layout_alignparentleft="true" android:layout_alignparentstart="true" android:orientation="vertical"> <linearlayout android:id="@+id/linearlayout" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginleft="100dp" android:layout_margintop="10dp" android:orientation="vertical"> <button android:id="@+id/btnbereken" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="calculate" android:textstyle="bold" /> <button android:id="@+id/btnreset" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="reset textfields" android:textstyle="bold" /> <button android:id="@+id/btnload" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="load latest results" android:textstyle="bold" /> </linearlayout> <com.google.android.gms.ads.adview android:id="@+id/adview" android:layout_width="wrap_content" android:layout_height="wrap_content" ads:adsize="smart_banner" ads:adunitid="my_id" /> </linearlayout> </relativelayout>
you can:
give sec linear layout , move button layout , advertisement layouts main layout. stick advertisement layout bottom , declare before button layout. set buttons adjustments layout_below="textfieldlayout" , layout_above="ad" instead of layout_alignparentbottom="true".
consider using linear layout weightsum. every parent layout should have weightsum=100, every kid respectively have % of space. point of view way best, because views position as simply devices , layout tree depth remain same. you'll have alter parent layout linearlayout , set weights.
android xml design
Comments
Post a Comment