Adding buttons programatically to DialogFragment are never displayed - android

So I am trying to add a button programatically to a DialogFragment but the button is never shown.
I have the following layout:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#99000000"
android:padding="10dp">
<RelativeLayout
android:id="#+id/notificationLayout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="#drawable/logo_background_shape"
android:padding="2dp"
android:layout_centerVertical="true"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/input_layout"
android:paddingBottom="20dp">
<TextView
android:id="#+id/start_date_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="Some text"
android:paddingLeft="10dp"
android:textColor="#color/my_blue"/>
</RelativeLayout>
<RelativeLayout
android:id="#+id/clickables_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/input_layout"
android:paddingBottom="10dp">
</RelativeLayout>
</RelativeLayout>
</RelativeLayout>
Here is the way I create my dialog's view:
#Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
/**
* Setup the dialog and its styles
*/
final Dialog dialog = new Dialog(getActivity(), android.R.style.Theme_Black_NoTitleBar_Fullscreen);
setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
final View view = getActivity().getLayoutInflater().inflate(R.layout.notification_fragment_layout, null);
final RelativeLayout relLayout = (RelativeLayout)getActivity().findViewById(R.id.clickables_layout);
RelativeLayout.LayoutParams paramsButton1 = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
paramsButton1.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
Button button1 = (Button) mDynamicNotification.getClickableList().get(0).getElementView(getActivity(), paramsButton1);
relLayout.addView(button1);
/**
* Code block handling blurring of the background
*/
final Drawable d = new ColorDrawable(Color.TRANSPARENT);
dialog.getWindow().setBackgroundDrawable(d);
dialog.getWindow().setContentView(view);
//allow the dialog to be canceled when touching outside of the dialog
dialog.setCanceledOnTouchOutside(false);
final Activity activity = getActivity();
final View content = activity.findViewById(android.R.id.content).getRootView();
if (content.getWidth() > 0) {
Bitmap image = BlurrBuilder.blur(content);
dialog.getWindow().setBackgroundDrawable(new BitmapDrawable(activity.getResources(), image));
} else
content.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
#Override
public void onGlobalLayout() {
Bitmap image = BlurrBuilder.blur(content);
dialog.getWindow().setBackgroundDrawable(new BitmapDrawable(activity.getResources(), image));
}
});
return dialog;
}
Problem:
The problem is that the button that I am adding is never shown in the layout once launched. It almost seems like the layout gets created before I add the button so the button is never shown...

The problem is that the button that I am adding is never shown in the
layout once launched
Because forget to add relLayout in Dialog layout which passing in dialog.getWindow().setContentView.
Use view.addView method to add Button in view :
relLayout.addView(button1);
view.addView(relLayout);

Related

how to show fragment from custom alertdialog, alert dialog is in adapter

i am trying to show fragment from a custom alertdilog's button click event, alert dialog is in fragment's adapter, i wanted to show fragment from alertdialog button click but i am unable to do so.
alertdialog code:
holder.commentButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
AlertDialog.Builder builder=new AlertDialog.Builder(context);
final AlertDialog alertDialog=builder.create();
View viewTmp_comment=LayoutInflater.from(context).inflate(R.layout.comment_show_layout,null,false);
RecyclerView recyclerView_commentShow=(RecyclerView)viewTmp_comment.findViewById(R.id.recyclerViewId_commentShow);
TextView textViewId_commentShow_layout=(TextView)viewTmp_comment.findViewById(R.id.textViewId_commentShow_layout);
ImageButton commentSendButtonId_Post=(ImageButton)viewTmp_comment.findViewById(R.id.commentSendButtonId_Post);
ImageButton imageUpload_CommentButton=(ImageButton)viewTmp_comment.findViewById(R.id.imageUploadButtonId_comment);
ImageButton smileyUpload_CommentButton=(ImageButton)viewTmp_comment.findViewById(R.id.smileyButtonId_comment);
editTextId_CommentPost=(EditText) viewTmp_comment.findViewById(R.id.editTextId_CommentPost);
// RelativeLayout smileyLoadLayoutId_CommentAdapter=(RelativeLayout)
final CommentShowAdapter commentShowAdapter=new CommentShowAdapter(context,newsFeedClassArrayList.get(position).getCommentShowClassArrayList(),"NewsFeed");
LinearLayoutManager linearLayoutManager=new LinearLayoutManager(context);
recyclerView_commentShow.setLayoutManager(linearLayoutManager);
if(newsFeedClassArrayList.get(position).getCommentShowClassArrayList()!=null) {
recyclerView_commentShow.setAdapter(commentShowAdapter);
DividerItemDecoration dividerItemDecoration = new DividerItemDecoration(context, linearLayoutManager.getOrientation());
recyclerView_commentShow.addItemDecoration(dividerItemDecoration);
commentShowAdapter.notifyDataSetChanged();
recyclerView_commentShow.onChildDetachedFromWindow(null);
}else {
builder.setMessage("No comments yet");
}
//comment show alert dismiss
textViewId_commentShow_layout.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
try {
if(alertDialog.isShowing()){
alertDialog.dismiss();
}
}catch (Exception e){}
}
});
**//here i am trying to lauch fragment**
smileyUpload_CommentButton.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
ServiceClass.setSmileyKey("comment");
smileyFragment=new SmileyShowFragment();
FragmentTransaction fragmentTransaction=fragmentManager.beginTransaction();
Fragment fragment = fragmentManager.findFragmentById(R.id.smileyLoadLayoutId_CommentAdapter);
if (!(fragment instanceof SmileyShowFragment)) {
fragmentTransaction.replace(R.id.smileyLoadLayoutId_CommentAdapter, smileyFragment, "Smiley").commit();
} else {
fragmentTransaction.remove(smileyFragment).commit();
}
}
});
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
Window window = alertDialog.getWindow(); lp.copyFrom(window.getAttributes());
lp.width = context.getResources().getDisplayMetrics().widthPixels;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
lp.gravity=Gravity.BOTTOM; window.setAttributes(lp);
alertDialog.setView(viewTmp_comment);
alertDialog.show();
}
});
alert xml code:
<?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="#ddd"
>
<TextView
android:layout_width="match_parent"
android:layout_height="40dp"
android:id="#+id/textViewId_commentShow_layout"
android:text="Comments"
android:textSize="16sp"
android:paddingLeft="20dp"
android:textStyle="bold"
android:paddingTop="10dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/underline"/>
<android.support.v7.widget.RecyclerView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:id="#+id/recyclerViewId_commentShow"
>
</android.support.v7.widget.RecyclerView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal"
android:weightSum="4"
android:background="#1470a6"
>
<ImageButton
android:layout_width="30dp"
android:layout_height="30dp"
android:background="#drawable/camera"
android:id="#+id/imageUploadButtonId_comment"
android:layout_gravity="center"
android:layout_marginLeft="8dp"
android:layout_marginRight="5dp"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/smileyButtonId_comment"
android:src="#drawable/smiley"
android:layout_gravity="center"
/>
<EditText
android:layout_width="wrap_content"
android:layout_height="60dp"
android:id="#+id/editTextId_CommentPost"
android:layout_weight="3"
android:background="#FFFFFF"
android:hint="Your comment"
android:textSize="16sp"
/>
<ImageButton
android:layout_width="30dp"
android:layout_height="match_parent"
android:id="#+id/commentSendButtonId_Post"
android:src="#drawable/send_comment"
android:background="#1470a6"
android:gravity="right"
android:layout_gravity="right"
android:layout_weight="1"
/>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/smileyLoadLayoutId_CommentAdapter"
>
</FrameLayout>
</LinearLayout>
how to solve this problem? is it possible to show fragment inside alertdialog.i have searched on google but no similar solution
You should create a separate customized dialog. To do so you can extend DialogFragment and on onCreateDialog() set up your views and proper assignments. Create a layout for your customized dialog fragment class with a fragment inside. You can create an interface on your customized dialog to listen for actions like button clicks or others. Then, onClick of your button use fragment manager to show the fragment within your dialogfragment. Something like below:
//Give it a fragment with a FrameLayout to hold the fragment if you
need to hold more than one or with just add a fragment in your layout
if you do not need a holder.
public class MyCustomizedDialog extends DialogFragment{
private TextView dialogTitle;
private TextView dialogText;
private FrameLayout myFragmentContainer;
private Button myButton;
private CustomDialogListener customDialogListener;
public interface CustomDialogListener{
//set listeners here, i.e. for buttons clicked by user
public void onBtnClick();
}
public setDialogFragmentListener(CustomDialogListener customDialogListener){
this.customDialogListener = customDialogListener;
}
#override
public Dialog onCreateDialog(Bundle savedInstanceState) {
//initialize dialog
setUpMyCustomDialog(dialog);
return dialog;
}
public void setUpMyCustomDialog(Dialog dialog){
dialogTitle = (TextView)dialog.findViewById(R.id.dialog_title_tv);
dialogText = (TextView)dialog.findViewById(R.id.dialog_text_tv);
myFragmentContainer=(FrameLayout)dialog.findViewById(R.id.child_fragment_container);
myButton = (Button)dialog.findViewById(R.id.myButton);
myButton.setOnClickListener(new OnClickListener(){
public void onClick(View view) {
//initialize your fragment here.
}
}
}
}

Make dialog smaller on screen

I want my dialog to not fit the whole screen like the image shown. How should i make it so it is not as long (height).
public class SidemenuInfoDialogFragment extends DialogFragment {
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.sidemenu_info_main, container, true);
return layout;
}
#Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Dialog dialog = new Dialog(new ContextThemeWrapper(getActivity(), R.style.Theme_Window_NoMinWith));
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
return dialog;
}
}
The View:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:id="#+id/sidemenu_info_main_relative">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/text1"
android:text="TEST TEXT "/>
</RelativeLayout>
Let me know if there is something else needed to be able to help me get on the right path of fixing this.
Give your textview inside your dialog view height and width as "wrap_content".Like:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:id="#+id/sidemenu_info_main_relative">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/text1"
android:text="TEST TEXT "/>
</RelativeLayout>
Try changing you xml:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:id="#+id/sidemenu_info_main_relative">
<TextView
android:layout_width="100dp"
android:layout_height="40dp"
android:id="#+id/text1"
android:text="TEST TEXT "/>
</RelativeLayout>
If that does not work with you here is another approach that I usually do :
public class PopUp {
public void poupUP(final Activity activity) {
final Dialog dialog = new Dialog(activity, R.style.dialogwithoutTitle);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
//here add the layout
dialog.setContentView(R.layout.pop_up);
// The comments are to change the position of the alert dialogu
// WindowManager.LayoutParams wmlp = dialog.getWindow().getAttributes();
//wmlp.gravity = Gravity.TOP | Gravity.END;
//wmlp.x = 100; //x position
//wmlp.y = 100; //y position
dialog.show();
}
}
Then wherever you want it to show do this :
PopUp p = new PopUp();
p.popUP();
RelativeLayout layout = (RelativeLayout) inflater.inflate(R.layout.sidemenu_info_main, container, false);
Try this:
alert.getWindow().setLayout(dialogWidth, LayoutParams.WRAP_CONTENT);
WindowManager.LayoutParams layoutParams = new WindowManager.LayoutParams();
layoutParams.copyFrom(alert.getWindow().getAttributes());
layoutParams.x = xPosition;
layoutParams.y = yPosition;
alert.getWindow().setAttributes(layoutParams);

Create a AlertDialog in Android with custom xml view

How to create a dialog like this in Android?
My idea is to create a custom xml view and inflate it into the dialog.
any other suggestions?
and what is the "drag line" at the middle of the dialog called? I really need that.
Thanks in advance
Try below code for your reference:
main.xml
<?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="fill_parent"
android:orientation="vertical" >
<Button
android:id="#+id/buttonShowCustomDialog"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Show Custom Dialog" />
</LinearLayout>
dialog.xml: Make design whatever you want in dialog.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ImageView
android:id="#+id/image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="5dp" />
<TextView
android:id="#+id/text"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#FFF"
android:layout_toRightOf="#+id/image"/>/>
<Button
android:id="#+id/dialogButtonOK"
android:layout_width="100px"
android:layout_height="wrap_content"
android:text=" Ok "
android:layout_marginTop="5dp"
android:layout_marginRight="5dp"
android:layout_below="#+id/image"
/>
</RelativeLayout>
MainActivity:
public class MainActivity extends Activity {
final Context context = this;
private Button button;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button) findViewById(R.id.buttonShowCustomDialog);
// add button listener
button.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View arg0) {
// custom dialog
final Dialog dialog = new Dialog(context);
dialog.setContentView(R.layout.dialog);
dialog.setTitle("Title...");
// set the custom dialog components - text, image and button
TextView text = (TextView) dialog.findViewById(R.id.text);
text.setText("Android custom dialog example!");
ImageView image = (ImageView) dialog.findViewById(R.id.image);
image.setImageResource(R.drawable.ic_launcher);
Button dialogButton = (Button) dialog.findViewById(R.id.dialogButtonOK);
// if button is clicked, close the custom dialog
dialogButton.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
}
});
}
}
Create Alert Dialog and Inflate Custom Layout and set layout to your Alert Dialog.
Here is the link for some demo examples for reference
http://examples.javacodegeeks.com/android/core/ui/dialog/android-custom-dialog-example/
http://www.mkyong.com/android/android-custom-dialog-example/
and drag line is called as Progress Bar/Seek Bar in android. You can add this into your layout and handle it's progress.
I think this is the standard dialog for android if you are using the Holo theme. You just need to use the holo theme for your application and it should work.
Add this to your application tag in your manifest file
android:theme="#android:style/Theme.Holo"

Android DialogFragment TextView setText() doesn't work

this is my onCreate() function:
#Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
//inflate the view
View view = getActivity().getLayoutInflater().inflate(R.layout.fragment_loading, null);
TextView loadingMessage = (TextView) view.findViewById(R.id.fragment_loading_message_textview);
loadingMessage.setText("test");
//the dialog
Dialog dialog;
//set the dialog views
int themeId = getDialogThemeId();
//if there is no theme
if (themeId == -1)
dialog = new Dialog(getActivity());
else
dialog = new Dialog(getActivity(),getDialogThemeId());
//remove background
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
//remove title
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
//set the content view
dialog.setContentView(view);
//set cancel properties
dialog.setCancelable(true);
dialog.setCanceledOnTouchOutside(true);
return dialog;
}
this is the layout i'm inflating:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:orientation="vertical"
android:background="#android:color/black">
<!-- spinner -->
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:background="#android:color/transparent" />
<!-- text -->
<TextView
android:id="#+id/fragment_loading_message_textview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:textAppearance="#android:style/TextAppearance.Large"
android:textColor="#android:color/white"
android:text="LOADING"/>
</LinearLayout>
although i'm calling loadingMessage.setText("test") the loading message is keeping showing me "LOADING" in the message... any idea???
ok i found the problem.
in the same DialogFragment I've implemented onCreateDialog and onCreateView as well.
This causes my view to be inflated twice. since onCreateView is called after onCreateDIalog, the view I've loaded in the onCreateDialog was overridden..
hope it will someone else

Button under ListView in AlertDialog is hidden

I want to show a list with a button under it in an AlertDialog. The Button is to close the Dialog itself. I extended AlertDialog and added some LayoutParams to the Window to extend the Dialog of the whole screen width:
//Grab the window of the dialog, and change the width
WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
Window window = getWindow();
lp.copyFrom(window.getAttributes());
//This makes the dialog take up the full width
lp.width = WindowManager.LayoutParams.MATCH_PARENT;
lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
window.setAttributes(lp);
ok. But if the list is long (display is full of it), I can scroll the ListView but the button is not shown under it. Here's the ContentView of the Dialog:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/choose_equipment_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:layout_below="#+id/choose_equipment_list"
android:id="#+id/btn_choose_equipment_close"
style="#style/custom_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="close" />
</RelativeLayout>
What can I do to show the button ALWAYS under the list, no matter how long it is? (I read a lot warnings to put a ListView inside a ScrollView, tried it anyway and failed...)
Try it:
<?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" >
<ListView
android:id="#+id/choose_equipment_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:id="#+id/btn_choose_equipment_close"
style="#style/custom_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="close" />
</LinearLayout>
If not work, remove the style="#style/custom_button" line. Some style configuration could change the view style and hide the button.
I want to show a list with a button under it in an AlertDialog.
So What you have to do is :
Remove this from from your Button:
android:layout_below="#+id/choose_equipment_list"
Then put this in Button:
android:layout_alignParentBottom="true"
And Put this in ListView:
android:layout_above="#+id/btn_choose_equipment_close"
You are Done.
Hmm. Maybe try to use Fragments. I coded sample for you. Tell me if it is what you are looking for:)
MainActivity.java
public class MainActivity extends ActionBarActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);
findViewById(R.id.open_dialog_button).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
SampleDialogFragment dialogFragment = new SampleDialogFragment();
dialogFragment.show(getSupportFragmentManager(), "dialogFragment");
}
});
}
}
main_activity.xml
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<Button
android:id="#+id/open_dialog_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Open dialog"
android:layout_gravity="center" />
</FrameLayout>
SampleDialogFragment.java
public class SampleDialogFragment extends DialogFragment {
#Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
alert.setTitle("Timer");
alert.setPositiveButton("OK", null);
View view = View.inflate(getActivity(), R.layout.dialog, null);
String[] array = {"Hello", "Hello", "Hello", "Hello", "Hello", "Hello", "Hello", "Hello", "Hello", "Hello", "Hello", "Hello", "Hello", "Hello", "Hello"};
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, array);
((ListView) view.findViewById(R.id.listView)).setAdapter(adapter);
alert.setView(view);
return alert.create();
}
}
dialog.xml
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/listView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
I think it could be possible to get what you need declaring in the XML your button first located in the bottom and then the listview above it with height set to fill_parent
This is should be what you want...
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/choose_equipment_list"
android:layout_above="#+id/btn_choose_equipment_close"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<Button
android:id="#+id/btn_choose_equipment_close"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="close" />
</RelativeLayout>

Categories

Resources