I need some help with my relativelayout. My "Close" button cant be seen when i launch my custom dialog. It can only be seen when i set my ScollView Height to around "200dp" . I do not want to manually set the height. Is there a way to accomplish it? Maybe using android:weightSum? Please show me how it is done. Thanks
OnMenuItemClickListener mAboutButtonClickListener = new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
final Dialog dialog = new Dialog(MainPageActivity.this);
dialog.setContentView(R.layout.about_us);
dialog.setTitle("About Us");
dialog.setCancelable(true);
TextView text = (TextView) dialog.findViewById(R.id.TextView01);
try {
Resources res = getResources();
InputStream in_s = res.openRawResource(R.raw.disclaimer);
byte[] b = new byte[in_s.available()];
in_s.read(b);
text.setText(new String(b));
} catch (Exception e) {
// e.printStackTrace();
text.setText("Error: can't show help.");
}
//set up button
Button button = (Button) dialog.findViewById(R.id.Button01);
button.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
dialog.show();
return false;
}
};
My xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<ScrollView android:id="@+id/ScrollView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:scrollbars="vertical"
android:scrollbarAlwaysDrawVerticalTrack="true">
<TextView android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</ScrollView>
<Button android:id="@+id/Button01"
android:layout_below="@+id/ScrollView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:text="Close"
android:layout_alignParentBottom="true"/>
</RelativeLayout>
You can use something like this.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/root"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="0dip"
android:layout_weight="1" >
<TextView android:id="@+id/TextView01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</ScrollView>
<Button android:id="@+id/Button01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Close" />
</LinearLayout>