android - Position of button changes when caption is too long -



android - Position of button changes when caption is too long -

i work on quiz app. there question , 4 possible reply options. each reply options represented button. 4 buttons aligned in rectangle.

problem: if button caption long, button position changes ns button slips downward.

question: there solution problem? dont want button alter position.

xml code

<relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:background="@drawable/background" > <textview android:id="@+id/tv_voc_trainer_question" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_alignparenttop="true" android:layout_centerhorizontal="true" android:layout_margintop="44dp" android:layout_marginleft="10dp" android:layout_marginright="10dp" android:gravity="center" android:text="this title!" android:textsize="20sp" /> <linearlayout android:id="@+id/ll_voc_trainer_first_answer_row" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/tv_voc_trainer_question" android:layout_margintop="40dp" android:orientation="horizontal" > <button android:id="@+id/bu_first_answer_possibility" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="10dp" android:layout_weight="1" android:background="@drawable/blue_button" android:text="answer 1" /> <button android:id="@+id/bu_second_answer_possibility" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="10dp" android:layout_weight="1" android:background="@drawable/blue_button" android:text="answer 2 long!" /> </linearlayout> <linearlayout android:id="@+id/ll_voc_trainer_second_answer_row" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_below="@+id/ll_voc_trainer_first_answer_row" android:orientation="horizontal" > <button android:id="@+id/bu_third_answer_possibility" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="10dp" android:layout_weight="1" android:background="@drawable/blue_button" android:text="answer 3" /> <button android:id="@+id/bu_fourth_answer_possibility" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_margin="10dp" android:layout_weight="1" android:background="@drawable/blue_button" android:text="answer 4" /> </linearlayout> <imageview android:id="@+id/img_trainer_answer" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_below="@+id/ll_voc_trainer_second_answer_row" android:layout_margintop="25dp" android:layout_centerhorizontal="true" android:contentdescription="answer" /> </relativelayout>

this screenshot illustrates problem. button 2 has longer caption , hence position automatically changed.

try using in linear layout:

android:baselinealigned="false"

android android-layout user-interface

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -