i started using wrap content , added padding between buttons, problem because on phones take half screen ended using weights. first problem buttons on page 1 have 0.5 of screen size , padding between them of 15dp each button has 0.5*screensize/7. if i'll same second view, buttons have height 0.5*screensize/3(therefore bigger heights). don't know how push 'post it' button @ bottom of page using weights. second problem want use weights width well(so far weight fixed of them), might lead performance issue(i'll use way many linear layouts) guys saying here android xml: percentage height , width create unique layout.
my code view1 picture coded in android
<?xml version="1.0" encoding="utf-8"?> <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/gradientf1" android:background="@drawable/gradient" android:orientation="vertical"> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.18" android:orientation="vertical" android:paddingtop="15dp"> <textview android:id="@+id/textview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:text="title1" android:textcolor="#fff" android:textsize="30dp" /> <textview android:id="@+id/textview3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center_horizontal" android:paddingtop="5dp" android:text="title2" android:textcolor="#fff" android:textsize="15dp" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.10" android:orientation="vertical"> <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_horizontal"> <imageview android:id="@+id/imageview" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginright="25dp" android:background="@drawable/first" /> <imageview android:id="@+id/imageview2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_centerhorizontal="true" android:layout_marginright="27dp" android:background="@drawable/second" /> <imageview android:id="@+id/imageview3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/third" /> </linearlayout> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.50" android:orientation="vertical"> <button android:id="@+id/button1" android:layout_width="270dp" android:layout_height="0dp" android:layout_gravity="center_horizontal" android:layout_margintop="15dp" android:layout_weight="1" android:background="@drawable/btnstyle" android:gravity="left|center_vertical" android:paddingleft="45dp" android:text="button1" android:textcolor="#fff" /> <button android:id="@+id/button2" android:layout_width="270dp" android:layout_height="0dp" android:layout_gravity="center_horizontal" android:layout_margintop="15dp" android:layout_weight="1" android:background="@drawable/btnstyle" android:gravity="left|center_vertical" android:paddingleft="45dp" android:text="button2" android:textcolor="#fff" /> <button android:id="@+id/button3" android:layout_width="270dp" android:layout_height="0dp" android:layout_gravity="center_horizontal" android:layout_margintop="15dp" android:layout_weight="1" android:background="@drawable/btnstyle" android:gravity="left|center_vertical" android:paddingleft="45dp" android:text="button3" android:textcolor="#fff" /> <button android:id="@+id/button4" android:layout_width="270dp" android:layout_height="0dp" android:layout_gravity="center_horizontal" android:layout_margintop="15dp" android:layout_weight="1" android:background="@drawable/btnstyle" android:gravity="left|center_vertical" android:paddingleft="45dp" android:text="button4" android:textcolor="#fff" /> <button android:id="@+id/button5" android:layout_width="270dp" android:layout_height="0dp" android:layout_gravity="center_horizontal" android:layout_margintop="15dp" android:layout_weight="1" android:background="@drawable/btnstyle" android:gravity="left|center_vertical" android:paddingleft="45dp" android:text="button5" android:textcolor="#fff" /> <button android:id="@+id/button6" android:layout_width="270dp" android:layout_height="0dp" android:layout_gravity="center_horizontal" android:layout_margintop="15dp" android:layout_weight="1" android:background="@drawable/btnstyle" android:gravity="left|center_vertical" android:paddingleft="45dp" android:text="button6" android:textcolor="#fff" /> </linearlayout> <linearlayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="0.22" android:layout_marginbottom="15dp" android:orientation="vertical"> <button android:id="@+id/button7" android:layout_width="wrap_content" android:layout_height="0dp" android:layout_gravity="center_horizontal" android:layout_margintop="15dp" android:paddingleft="5dp" android:paddingright="5dp" android:layout_weight="1" android:text="next step" android:background="@drawable/nxtbtn" android:textcolor="#fff" /> <button android:id="@+id/button8" android:layout_width="220dp" android:layout_height="0dp" android:layout_gravity="center_horizontal" android:layout_margintop="15dp" android:paddingleft="5dp" android:paddingright="5dp" android:layout_weight="1" android:background="@drawable/nxtbtn" android:text="post it" android:textcolor="#fff" /> </linearlayout> </linearlayout>
is there other way of coding 2 images in android ? , can see don't have yet + @ end of button. + turn in approved('tick' sign) once users completes data opened clicking button(i haven t done of fragments yet).i'm sorry size of images, couldn t find how resize them
update: i'm trying have same on phones. thought can using weight , linear layouts, it's quite tricky.
two things:
1) use relativelayout
main container, can align "post it" button bottom android:layout_alignparentbottom="true"
, "button-container" (centered etc).
2) better testing, should use style buttons, like:
in /res/values/styles.xml
:
<style name="custombutton"> <item name="android:layout_width">fill_parent</item> <item name="android:layout_height">wrap_content</item> <item name="android:layout_margintop">15dp</item> <item name="android:layout_weight">1</item> etc... </style>
in layout:
<button android:id="@+id/button4" style="@style/custombutton"/>
hope helps bit.
Comments
Post a Comment