Dialog custom title to match non-custom title - android

One of my dialogs has a non-custom title:
NameDialog.java
public class NameDialog extends DialogFragment {
#Override
#NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
return builder.setTitle(R.string.name)
.setView(inflater.inflate(R.layout.name_dialog, null))
.setPositiveButton(R.string.next, null)
.create();
}
}
name_dialog.xml
<?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:orientation="vertical">
<EditText
android:id="#+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:ems="10"
android:inputType="textPersonName"
android:textAppearance="?android:attr/textAppearanceLarge"/>
</LinearLayout>
This is what it looks like:
One of my dialogs has a custom title with the cast icon.
PlayersDialog.java
public class PlayersDialog extends DialogFragment {
#Override
#NonNull
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
LayoutInflater inflater = getActivity().getLayoutInflater();
return builder
.setCustomTitle(inflater.inflate(R.layout.players_title_dialog, null))
.setView(inflater.inflate(R.layout.players_dialog, null))
.setPositiveButton(R.string.start_game, null)
.create();
}
}
players_dialog.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"
tools:context=".PlayersDialog">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:textAppearance="?android:attr/textAppearanceLarge"/>
<ListView
android:id="#+id/players"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clickable="false"/>
</RelativeLayout>
players_title_dialog.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:orientation="horizontal"
tools:context=".PlayersDialog">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/title"
android:text="#string/players"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:layout_marginLeft="5dp"/>
<android.support.v7.app.MediaRouteButton
android:id="#+id/media_route_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:mediaRouteTypes="user"
android:visibility="gone"/>
</RelativeLayout>
This is what it looks like:
I just want both dialogs to have consistent formatting.

In your players_title_dialog.xml file replace the players textView with the following
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/title"
android:text="#string/players"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#3db6e3"
android:layout_marginLeft="10dp"/>
And may be the font size could be decreased by 1dp and padding could be added 3px in you list

Related

popup window button not working

I am developing app having a popup window showing successfully but button inside is not working. When the button is click the event is not listening. The code is shown below.
private void showPopup() {
//LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(LAYOUT_INFLATER_SERVICE);
LayoutInflater inflater = (LayoutInflater)getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);
View customView = inflater.inflate(R.layout.popup_layout,null);
mPopupWindow = new PopupWindow(
customView,
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT
);
Button btn_popup_submit = (Button)customView.findViewById(R.id.btn_popup_submit);
Button btn_popup_cancel = (Button)customView.findViewById(R.id.btn_popup_cancel);
btn_popup_submit.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(), "aaa", Toast.LENGTH_SHORT).show();
Log.d("LOG","aaaa");
}
});
btn_popup_cancel.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Toast.makeText(getApplicationContext(), "bbbb", Toast.LENGTH_SHORT).show();
Log.d("LOG","bbbb");
}
});
if(Build.VERSION.SDK_INT>=21){
mPopupWindow.setElevation(5.0f);//5.0f
}
mPopupWindow.showAtLocation(mRelativeLayout, Gravity.CENTER,0,0);
mPopupWindow.setFocusable(true);
mPopupWindow.setBackgroundDrawable(new ColorDrawable(ContextCompat.getColor(mContext, android.R.color.transparent)));
mPopupWindow.setOutsideTouchable(false);
mPopupWindow.setTouchable(false);
mPopupWindow.update();
}
The pop up layout code is
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/rl_custom_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="2dp"
android:background="#5b5e93"
>
<TextView
android:id="#+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email Sent."
android:textSize="20sp"
android:textColor="#color/colorWhite"
android:padding="25sp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="5dp"
android:layout_above="#+id/editText"
android:layout_marginBottom="50dp"
android:background="#color/colorGray"
android:orientation="horizontal"></LinearLayout>
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="#+id/tv"
android:layout_centerHorizontal="true"
android:layout_marginTop="76dp"
android:textSize="16sp"
android:textColor="#color/colorWhite"
android:text="#string/email_sent" />
<EditText
android:id="#+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView2"
android:ems="4"
android:maxLength="4"
android:minLines="4"
android:inputType="number" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_below="#+id/editText"
android:layout_marginBottom="10dp"
android:orientation="horizontal"
android:weightSum="2">
<Button
android:id="#+id/btn_popup_submit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#drawable/buttoncolor"
android:text="Submit"
android:textAllCaps="false" />
<Button
android:id="#+id/btn_popup_cancel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_weight="1"
android:background="#drawable/buttoncolor"
android:text="Cancel"
android:textAllCaps="false" />
</LinearLayout>
</RelativeLayout>
The button names are btn_popup_submit and btn_popup_cancel.
I tried different methods but the problem. I don't know where is the problem facing. Please help me thanks.
Replace this line of code.Allow popWindow Touch.
mPopupWindow.setTouchable(false);
to
mPopupWindow.setTouchable(true);

Adjusting height of a Custom layout in a dialog

I have a dialog with custom layout, everything is working fine, except there is a big empty spaces at the bottom which i cannot remove.
Any suggestion how i can remove that empty space.
Here is my Code:
public Dialog onCreateDialog() {
final AlertDialog.Builder builder = new AlertDialog.Builder(
this);
// Get the layout inflater
LayoutInflater inflater = getLayoutInflater();
// Inflate and set the layout for the dialog
// Pass null as the parent view because its going in the dialog layout
builder.setView(inflater.inflate(R.layout.dialogue_cover_staying, null))
// Add action buttons
.setPositiveButton("Done", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int id) {
//action
}
})
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
finish();
}
});
return builder.show();
}
My XML Layout:
`
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/back1"
android:orientation="vertical">
<TextView
android:id="#+id/textView2"
android:layout_width="match_parent"
android:layout_height="60dp"
android:layout_weight="0.00"
android:background="#drawable/box"
android:gravity="center_vertical"
android:text="Enter Covers and Guest Type"
android:textAppearance="?android:attr/textAppearanceLarge" />
<EditText
android:id="#+id/et_covers"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:layout_marginLeft="4dp"
android:layout_marginRight="4dp"
android:layout_marginTop="35dp"
android:fontFamily="sans-serif"
android:hint="Covers"
android:inputType="number" />
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="30dp"
android:fontFamily="sans-serif"
android:text="Staying Guest...?"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="15dp" >
<CheckBox
android:id="#+id/checkYes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="50dp"
android:text="YES" />
<CheckBox
android:id="#+id/checkNo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="75dp"
android:text="NO" />
</LinearLayout>
</LinearLayout> `
Change your layout width and height from "wrap_content" to "100dp" for example..like this..
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="100dp"
android:layout_height="200dp"
android:background="#drawable/back1"
android:orientation="vertical" >
Moreover you can set minWidth and minHeight..
android:minWidth="300dp"
android:minHeight="400dp"

how to remove title from DialogFragment?

I am using DialogFragment in my project and I'am disabling the Title using
getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
but my dialog has become crooked. I want to leave the dialog as it is and just remove Title. How can I do?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ff2d35ff">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="39dp"
android:layout_marginLeft="39dp"
android:layout_gravity="center_horizontal"
android:background="#ff6cff23">
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ItemName"
android:id="#+id/itemName"
android:layout_weight="1"
android:background="#ffd861ff"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="ItemPrice"
android:id="#+id/itemPrice"
android:layout_weight="1"
android:background="#ff2ff8ff"/>
</LinearLayout>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:id="#+id/itemImage"
android:layout_gravity="center_horizontal"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="some test"
android:id="#+id/textView9"
android:layout_gravity="center_horizontal"/>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center_horizontal"
android:background="#ffffff2c">
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:id="#+id/itemMinus"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="1"
android:id="#+id/textView11"
android:layout_weight="1"
android:gravity="center_horizontal"/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:id="#+id/itemPlus"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="fill_parent"
android:layout_gravity="center_horizontal"
android:gravity="center_horizontal">
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/itemAdd"
android:src="#drawable/positive"
android:background="#android:color/transparent"/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/itemCancel"
android:src="#drawable/negative"
android:background="#android:color/transparent"/>
</LinearLayout>
I realized that when I remove Title dialog can not found match_parent
I usually override onCreate in my DialogFragment's subclass and call setStyle(STYLE_NO_TITLE, 0);
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(STYLE_NO_TITLE, 0);
}
Here you can find the documentation for setStyle. The documentation for STYLE_NO_TITLE says:
Style for setStyle(int, int): don't include a title area.
you must override onCreateDialog method in your dialogfragment class.
#Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
RelativeLayout root = new RelativeLayout(getActivity());
root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
final Dialog dialog = new Dialog(getActivity());
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setContentView(root);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.WHITE));
dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
return dialog;
}
You can implement is simpler way like below code -
Dialog dialog = new Dialog(mContext, android.R.style.Theme_Black_NoTitleBar);
or
Dialog dialog = new Dialog(mContext, android.R.style.Theme_Black_NoTitleBar_Fullscreen);

How to set a view for AlertDialog in android?

I want to set a custom view for my alert dialog. Actually I have a grid view and I want to show a dialog when each item clicked, I built a function as ToastWarning and it builds my alert dialog. This is my xml for custom view: an imageview, textview and 2 button:
But this code is not working.why?
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/linear_toast"
android:gravity="right"
android:background="#drawable/white"
>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="right"
>
<TextView
android:id="#+id/tv_Toast"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="TextView"
android:textSize="18sp"
android:textColor="#FFFFFF"
android:layout_margin="10dp" />
<ImageView
android:id="#+id/iv_toast"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_marginRight="7dp"
android:layout_marginTop="10dp"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="right"
android:weightSum="10"
android:padding="5dp">
<Button
android:id="#+id/bt_no"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:layout_weight="5"
android:textColor="#FFFFFF" />
<Button
android:id="#+id/bt_yes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
android:layout_weight="5"
android:textColor="#FFFFFF" />
</LinearLayout>
</LinearLayout>
It's my code for building a alert dialog:
private void ToastWarning() {
LayoutInflater inflater = getLayoutInflater();
View view = inflater.inflate(R.layout.toast, null);
iv_alert=(ImageView)view.findViewById(R.id.iv_toast);
tv_alert=(TextView)view.findViewById(R.id.tv_Toast);
bt_yes=(Button)view.findViewById(R.id.bt_yes);
bt_yes=(Button)view.findViewById(R.id.bt_no);
iv_alert.setBackgroundResource(R.drawable.facebook);
tv_alert.setTypeface(face);
bt_yes.setTypeface(face);
bt_no.setTypeface(face);
bt_yes.setText(PersianReshape.reshape("بله"));
bt_no.setText(PersianReshape.reshape("خیر"));
tv_alert.setText(PersianReshape.reshape("فیلدهای مورد نظر پر شود."));
AlertDialog MyDialog;
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setView(view);
MyDialog=builder.create();
MyDialog.show();
}

Holoeverywhere dialog wrong layout - Sony Xperia Neo V 2.3.x

There is quite strange and bad error on devices from sony family.
I have implemented actually the same code as it was in example.
There is a problem with dialog layout which show very very strange behaviour.
So far I don't know how to fix it.
Here is the picture:
Here is my code:
public class DialogFragmentRadioChannelAdd extends DialogFragment {
private DialogInterface.OnClickListener listener;
private AddChannelListener addChannelListener;
public DialogFragmentRadioChannelAdd() {
setDialogType(DialogType.AlertDialog);
}
#Override
public AlertDialog onCreateDialog(Bundle savedInstanceState) {
LayoutInflater inflater = LayoutInflater.from(getActivity());
View dialoglayout = inflater.inflate(R.layout.add_channel, null);
final EditText channelAddTitle = (EditText) dialoglayout.findViewById(R.id.addChannelTitle);
final EditText channelAddUrl = (EditText) dialoglayout.findViewById(R.id.addChannelUrl);
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(("Dodaj kanał radiowy"));
builder.setView(dialoglayout);
builder.setPositiveButton("Zapisz", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialogInterface, int i) {
if (addChannelListener != null)
addChannelListener.onSave(dialogInterface, i, channelAddTitle, channelAddUrl);
}
})
.setNegativeButton("Anuluj", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialogInterface, int i) {
if (addChannelListener != null)
addChannelListener.onCancel(dialogInterface, i);
}
});
return builder.create();
}
public void setAddChannelListener(AddChannelListener addChannelListener)
{
this.addChannelListener = addChannelListener;
}
}
And here is the xml code:
<?xml version="1.0" encoding="utf-8"?>
<org.holoeverywhere.widget.LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="wrap_content"
android:layout_height="match_parent"
android:padding="1dp"
android:layout_margin="1dp"
>
<org.holoeverywhere.widget.EditText
android:id="#+id/addChannelTitle"
android:minWidth="250dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:hint="Wpisz tytuł kanału radiowego"/>
<org.holoeverywhere.widget.EditText
android:id="#+id/addChannelUrl"
android:layout_below="#id/addChannelTitle"
android:minWidth="250dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:hint="Wpisz adres url kanału radiowego"/>
</org.holoeverywhere.widget.LinearLayout>
Someone was talking to replace linearlayout with something else in root but I don't have so much experience to find out the solution. As I said the problem is usualy with sony family in android 2.3.+
Edit:
So I spend some time to find out any hack.
Here is a link to show what did I changed (hosted on diff comparator 1year)(or the right comparing to original code on the left) Link to compartor with changes.
What I did is just changing linear layout into relative in base holoeverywhere layout called alert_dialog_holo.xml found in holoeverywhere library in res/layout
Fixed alert_dialog.xml layout for version holoeverywhere (dont know but today is 22-12-2013 so I think it is 2.1.0)
<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp"
android:layout_height="wrap_content"
android:id="#+id/parentPanel"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/topPanel"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="2dip"
android:id="#+id/titleDividerTop"
android:background="#color/holo_blue_light"
android:visibility="gone" />
<LinearLayout
android:layout_below="#+id/titleDividerTop"
android:layout_width="match_parent"
android:layout_marginRight="16dip"
android:layout_marginLeft="16dip"
android:gravity="center_vertical|left"
android:minHeight="#dimen/alert_dialog_title_height"
android:layout_height="wrap_content"
android:id="#+id/title_template"
android:orientation="horizontal">
<ImageView
android:layout_width="wrap_content"
android:paddingRight="8dip"
android:layout_height="wrap_content"
android:id="#+id/icon"
android:contentDescription="#string/loading"></ImageView>
<Internal.DialogTitle
android:layout_width="match_parent"
style="?android:windowTitleStyle"
android:ellipsize="end"
android:singleLine="true"
android:layout_height="wrap_content"
android:id="#+id/alertTitle"></Internal.DialogTitle>
</LinearLayout>
<View
android:layout_below="#+id/title_template"
android:layout_width="match_parent"
android:layout_height="2dip"
android:id="#+id/titleDivider"
android:background="?alertDialogTitleDividerColor"
android:visibility="gone"></View>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/contentPanel"
android:orientation="vertical">
<ScrollView
android:layout_width="match_parent"
android:clipToPadding="false"
android:layout_height="wrap_content"
android:id="#+id/scrollView">
<TextView
android:layout_width="match_parent"
style="?android:attr/textAppearanceMedium"
android:paddingBottom="8dip"
android:paddingLeft="16dip"
android:paddingRight="16dip"
android:layout_height="wrap_content"
android:paddingTop="8dip"
android:id="#+id/message" />
</ScrollView>
</RelativeLayout>
<RelativeLayout
android:layout_below="#+id/scrollView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/customPanel">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/custom"></FrameLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:minHeight="#dimen/alert_dialog_button_bar_height"
android:layout_height="wrap_content"
android:id="#+id/buttonPanel"
android:orientation="vertical">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:id="#+id/buttonPanelTopDivivder"
android:background="?dividerHorizontal" />
<LinearLayout
android:layout_width="match_parent"
style="?buttonBarStyle"
android:measureWithLargestChild="true"
android:layout_height="wrap_content"
android:orientation="horizontal">
<Button
android:layout_width="wrap_content"
android:layout_gravity="left"
style="?buttonBarButtonStyle"
android:minHeight="#dimen/alert_dialog_button_bar_height"
android:textSize="14sp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/button2"
android:maxLines="2"></Button>
<Button
android:layout_width="wrap_content"
android:layout_gravity="center_horizontal"
style="?buttonBarButtonStyle"
android:minHeight="#dimen/alert_dialog_button_bar_height"
android:textSize="14sp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/button3"
android:maxLines="2"></Button>
<Button
android:layout_width="wrap_content"
android:layout_gravity="right"
style="?buttonBarButtonStyle"
android:minHeight="#dimen/alert_dialog_button_bar_height"
android:textSize="14sp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="#+id/button1"
android:maxLines="2"></Button>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
You will get some errors in library's code but you need just to change it to relative where is linear
I am talking about class AlertController.java also stored in holoeverywhere libary in /src/widget/.
For listview/singlechoicemenu in dialog and according to up xml you need change some code in AlertController in method setupContent(xxx)
private void setupContent(RelativeLayout contentPanel) {
mScrollView = (ScrollView) mWindow.findViewById(R.id.scrollView);
mScrollView.setFocusable(false);
mMessageView = (TextView) mWindow.findViewById(R.id.message);
if (mMessageView == null) {
return;
}
if (mMessage != null) {
mMessageView.setText(mMessage);
} else {
mMessageView.setVisibility(View.GONE);
mScrollView.removeView(mMessageView);
if (mListView != null) {
contentPanel.removeView(mWindow.findViewById(R.id.scrollView));
contentPanel.addView(mListView, new RelativeLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT));
contentPanel.setLayoutParams(new LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
} else {
contentPanel.setVisibility(View.GONE);
}
}
}

Categories

Resources