Click here to Skip to main content
15,896,154 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have designed custom dialog window in Android. My design like as below:

Alert
-------------------------
Icon Alert message

Ok

Here left side is icon image and right side should be display the alert information message. Now its coming correctly. But when alert message is more than 2 lines icon should be display in the center. But now its displaying always in the top. Same like if alert message is only single line its should be display in the middle of the icon.

My xml code is,


<relativelayout xmlns:android="http://schemas.android.com/apk/res/android">
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:removed="@drawable/custom_dialog_curve"
android:orientation="horizontal"
android:padding="5dip" >

<textview>
android:id="@+id/txtTitle"
android:layout_width="fill_parent"
android:layout_height="30dp"
android:layout_alignParentTop="true"
android:layout_marginLeft="10dp"
android:textColor="#FF7F27"
android:textSize="15sp"
android:textStyle="bold" />

<view>
android:id="@+id/line"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/txtTitle"
android:removed="#FF7F27" />

<ImageView
android:id="@+id/imgDialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_below="@+id/line"
android:layout_marginRight="6dp"
android:contentDescription="@string/imgdescription"
/>

<textview>
android:id="@+id/txtDialog"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/line"
android:layout_toRightOf="@+id/imgDialog"
android:gravity="center_vertical"
android:textColor="#000000" />

<Button
android:id="@+id/btnOk"
android:layout_width="75dp"
android:layout_height="25dp"
android:layout_below="@+id/txtDialog"
android:layout_centerHorizontal="true"
android:layout_centerInParent="true"
android:background="@drawable/sign_in"
android:text="@string/okbtn" />



How to sort out...
Posted
Updated 1-Jan-15 19:16pm
v6
Comments
Richard MacCutchan 2-Jan-15 5:03am    
You need to add the centerVertical property to your button.
Richard MacCutchan 2-Jan-15 5:05am    
I also deleted your duplicate of this question; please post once only.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900