Inflating View using Dialog Fragment - android

I am inflating a view using Dialog Fragment.Everything works fine till API 23+ but when I am testing it on API 19, I am getting a blue line over my view.I can not even find the color of this line in my color.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#B3000000"
android:orientation="vertical">
<TextView
android:id="#+id/add_text_done_tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_margin="20dp"
android:background="#drawable/rounded_border_text_view"
android:padding="10dp"
android:text="Done"
android:textAllCaps="false"
android:textColor="#color/white"
android:textSize="15sp" />
<EditText
android:id="#+id/add_text_edit_text"
style="#style/EditText"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/add_text_color_picker_relative_layout"
android:layout_below="#+id/add_text_done_tv"
android:background="#null"
android:gravity="center"
android:inputType="textMultiLine"
android:textSize="40sp" />
<LinearLayout
android:id="#+id/add_text_color_picker_relative_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:layout_alignParentBottom="true">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/add_text_font_picker_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:background="#android:color/black"
tools:listitem="#layout/font_picker_list_item" />
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/add_text_color_picker_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:background="#android:color/black"
tools:listitem="#layout/color_picker_item_list" />
</LinearLayout>
</RelativeLayout>
I have added this code in my class onStart() to set the size of layout.
int width = ViewGroup.LayoutParams.MATCH_PARENT;
int height = ViewGroup.LayoutParams.MATCH_PARENT;
dialog.getWindow().setLayout(width, height);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

The following is your answer.
https://stackoverflow.com/a/37738741/9224262
Also I think you should have searched first. Anyway good luck.

You should hide the title:
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);

Related

set transperent background for constraint layout in android

hi I have to make a view like the below image .
But when i make the parent view transperent , default background is showing like this:
a transperent view is showing behind the main view.
my xml starts like :
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/_8sdp"
android:background="#color/red"
android:clipChildren="false"
android:clipToPadding="false">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/cl2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_50sdp"
android:background="#drawable/rounded_corner_shadow"
android:clipChildren="false"
android:clipToPadding="false"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout
android:id="#+id/progressLayout_frame"
android:layout_width="#dimen/_90sdp"
android:layout_height="#dimen/_90sdp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:clickable="true"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<View
android:id="#+id/bgCircle"
android:layout_width="#dimen/_70sdp"
android:layout_height="#dimen/_70sdp"
android:layout_gravity="center"
android:alpha="0.7"
android:background="#color/white"
android:visibility="visible" />
<RelativeLayout
android:id="#+id/progressLayout"
android:layout_width="#dimen/_80sdp"
android:layout_height="#dimen/_80sdp"
android:layout_gravity="center"
android:background="#android:color/transparent"
android:clickable="true"
>
<ProgressBar
android:id="#+id/progressbar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="#dimen/_80sdp"
android:layout_height="#dimen/_80sdp"
android:layout_centerHorizontal="true"
android:background="#drawable/circle_shape"
android:progressDrawable="#drawable/circular_progress_bar" />
<TextView
android:id="#+id/tvTimeCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginTop="60dp"
android:text="00:00"
android:textColor="#FFFFFF"
android:textSize="29sp"
app:customTypeFace="roboto_light" />
how can I hide the view behind . why does this layout come ? any suggestions would be helpful . thanks in advance
To remove default background of the dialog...
Step 1:
Create a custom_dialog.xml
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginHorizontal="#dimen/_20sdp"
android:paddingHorizontal="#dimen/_25sdp"
android:paddingVertical="#dimen/_25sdp" >
<androidx.constraintlayout.widget.Guideline
android:id="#+id/left_vertical_gl"
android:layout_width="match_parent"
android:layout_height="0dp"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.02" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/right_vertical_gl"
android:layout_width="match_parent"
android:layout_height="1dp"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.98" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/center_horizontal_gl"
android:layout_width="match_parent"
android:layout_height="1dp"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.48" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/top_horizontal_gl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.044" />
<androidx.constraintlayout.widget.Guideline
android:id="#+id/end_horizontal_gl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.90" />
<TextView
android:id="#+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="#font/segui_black"
android:text="Are You Sure?"
android:textColor="#484A67"
android:textSize="#dimen/_24ssp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/top_horizontal_gl" />
<TextView
android:id="#+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_2sdp"
android:layout_marginBottom="12dp"
android:fontFamily="#font/segoe"
android:gravity="center"
android:text="Are you sure you want to sign out?"
android:textColor="#484A67"
android:textSize="#dimen/_11ssp"
app:layout_constraintEnd_toStartOf="#+id/right_vertical_gl"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textView9" />
<TextView
android:id="#+id/yesTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_20sdp"
android:fontFamily="#font/segui_semi_bold"
android:padding="#dimen/_5sdp"
android:text="Yes"
android:textColor="#AD7BFF"
app:layout_constraintEnd_toStartOf="#+id/right_vertical_gl"
app:layout_constraintTop_toBottomOf="#+id/textView10" />
<TextView
android:id="#+id/noTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="#dimen/_30sdp"
android:fontFamily="#font/segoe"
android:padding="#dimen/_5sdp"
android:text="No"
android:textColor="#6D6E85"
app:layout_constraintBottom_toBottomOf="#+id/yesTv"
app:layout_constraintEnd_toStartOf="#+id/yesTv"
app:layout_constraintTop_toTopOf="#+id/yesTv"
tools:layout_editor_absoluteX="143dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
Step 2:
Go to your dialog activity
Add the below line to your dialog code
popUpDialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
Complete code of the dialog
private lateinit var popUpDialog: Dialog
private fun buyLifeLineDialog() {
popUpDialog.setContentView(R.layout.dialog_buy_lifelines)
popUpDialog.window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
val yesTv = popUpDialog.findViewById<TextView>(R.id.yesTv);
val noTv = popUpDialog.findViewById<TextView>(R.id.noTv);
popUpDialog.show()
yesTv.setOnClickListener {
if (isCheatLl) {
mViewModel.buyCheatLifeline(index,lifeLinesPackagesModel)
}
else{
mViewModel.buyRespawnLifeline(index,lifeLinesPackagesModel)
}
popUpDialog.dismiss()
}
noTv.setOnClickListener {
popUpDialog.dismiss()
}
}
I don't know how do you display this window in your app , but I suppose that you display it as custom dialog , so the problem is that you need to add a transparent theme for your dialog to get the same design or your dialog will fill the transparent spaces with this black color or white depends on your app theme , so to solve this problem you need to add this style in your theme.xml file or style.xml
<style name="AlertDialogCustom" parent="#android:style/Theme.Dialog">
<item name="android:windowBackground">#android:color/transparent</item>
</style>
and then you create a new custom dialog in your activity like this
//Here i will create new dialog with a custom style which I added in Theme.xml
final AlertDialog dialog2 = new AlertDialog.Builder(MainActivity.this,R.style.AlertDialogCustom).create();
LayoutInflater inflater = getLayoutInflater();
//Here I added my xml file , you can replace test with your own xml file
View convertView = (View) inflater.inflate(R.layout.test, null);
dialog2.setView(convertView);
dialog2.setCancelable(false);
//Here we tell the dialog to display , you can call show() when click a button
dialog2.show();
and here it's my simple design to get a transparent background
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="350dp"
android:layout_margin="8dp"
android:background="#android:color/transparent"
android:clipChildren="false"
android:clipToPadding="false">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/cl2"
android:layout_width="350dp"
android:layout_height="350dp"
android:layout_marginTop="50dp"
android:background="#FFFFFF"
android:clipChildren="false"
android:clipToPadding="false"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<FrameLayout
android:id="#+id/progressLayout_frame"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_gravity="center_horizontal"
android:layout_marginTop="10dp"
android:clickable="true"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<View
android:id="#+id/bgCircle"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_gravity="center"
android:background="#drawable/pers_icon"
android:visibility="visible" />
<RelativeLayout
android:id="#+id/progressLayout"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_gravity="center"
android:background="#android:color/transparent"
android:clickable="true">
</RelativeLayout>
</FrameLayout>
<Button
android:id="#+id/button2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"
tools:layout_editor_absoluteX="218dp"
tools:layout_editor_absoluteY="129dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
Now this is the final result , you can make your own design

How to set bottom edge to CardView as Fab shape in BottomAppBar?

I would make an insert FAB in my CardView like the one set by default in the BottomAppBar.
I changed my CardView to MaterialCardView to change the bottom edge bu setting the BottomAppBarTopEdgeTreatment
The issue is that i'm playing with the fabMargin, roundedCornerRadius, cradleVerticalOffset and fabDiameter but i can't set it's values to get the result from the native BottomAppBar inset FAB.
so which values should i set in it?
Desired behaviour would be like this (Actual picture of my BottomAppBar):
While i get this (Actual picture of my CardView):
My FAB code looks like this:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/btnScan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:contentDescription="#string/nuovo_documento"
android:translationY="-36dp"
app:layout_anchor="#id/cardView"
app:layout_anchorGravity="bottom|center"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/cardView"
app:srcCompat="#drawable/ic_outline_qr_code_scanner"
app:tint="#color/white" />
And the code where i set the shape to the Card is the following:
val bottomAppBarTreatment = BottomAppBarTopEdgeTreatment(16f, 2f, 8f)
bottomAppBarTreatment.fabDiameter = 110f
cardView.shapeAppearanceModel = cardView.shapeAppearanceModel.toBuilder()
.setBottomEdge(bottomAppBarTreatment)
.build()
You can use something like:
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/btnScan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:translationY="24dp"
../>
and:
val bottomAppBarTopEdgeTreatment = BottomAppBarTopEdgeTreatment(
resources.getDimension(R.dimen.margin), //5dp
resources.getDimension(R.dimen.rounded_corner), //8dp
resources.getDimension(R.dimen.vertical_offset) //0dp
)
bottomAppBarTopEdgeTreatment.fabDiameter = resources.getDimension(R.dimen.diameter) //56dp
cardView.shapeAppearanceModel = cardView.shapeAppearanceModel.toBuilder()
.setTopEdge(bottomAppBarTreatment)
.build()
I'm using below code snippet to achive this result using background image like below.
XML File:
<?xml version="1.0" encoding="utf-8"?>
<androidx.drawerlayout.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
tools:openDrawer="start">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#android:color/transparent">
<RelativeLayout
android:id="#+id/rr_fab_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/ll_bottom_nav"
android:layout_below="#+id/ll_top"
android:background="#android:color/transparent">
<LinearLayout
android:id="#+id/ll_last"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#android:color/transparent"
android:foreground="#android:color/transparent"
android:orientation="horizontal">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:background="#android:color/transparent"
android:foreground="#android:color/transparent">
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="#+id/fac_home"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="#dimen/padding_10"
app:backgroundTint="#color/colorPrimary"
app:srcCompat="#mipmap/home" />
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
<LinearLayout
android:id="#+id/ll_bottom_nav"
android:layout_width="match_parent"
android:layout_height="#dimen/padding_50"
android:layout_alignParentBottom="true"
android:layout_centerVertical="true"
android:layout_marginTop="-25dp"
android:background="#drawable/cut_nav_full_another_grey_two"
android:gravity="center"
android:orientation="horizontal"
android:weightSum="10"
app:layout_behavior="com.wpa3.productshopify.widget.BottomNavigationViewBehavior">
<TextView
android:id="#+id/tv_category"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.2"
android:drawableTop="#mipmap/category"
android:gravity="center"
android:text="#string/category"
android:textColor="#color/gray71"
android:textSize="#dimen/text_size_16" />
<TextView
android:id="#+id/tv_orders"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.5"
android:drawableTop="#mipmap/order"
android:gravity="center"
android:text="#string/track_your_order"
android:textColor="#color/gray71"
android:textSize="#dimen/text_size_16" />
<View
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="#android:color/transparent" />
<TextView
android:id="#+id/tv_profile"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2.5"
android:drawableTop="#mipmap/profile"
android:gravity="center"
android:text="#string/my_account"
android:textColor="#color/gray71"
android:textSize="#dimen/text_size_16" />
<TextView
android:id="#+id/tv_more"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.8"
android:drawableTop="#mipmap/more"
android:gravity="center"
android:text="#string/more"
android:textColor="#color/gray71"
android:textSize="#dimen/text_size_16" />
</LinearLayout>
</RelativeLayout>
</androidx.drawerlayout.widget.DrawerLayout>
Background Image = https://imgur.com/a/3cOhy9E
Hope this may helps you.

How to remove padding from circular progressbar?

I have a circular ProgressBar where I want to place an image inside as shown in the screenshot, the circular progress bar have a default padding I guess ,So I need to remove it so both will have the same dimensions :
enter image description here
here is the code for the layout :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/dikritem"
android:orientation="vertical">
<ProgressBar
style="?android:progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/buttons"
android:layout_centerInParent="true"
android:layout_margin="0dp"
android:paddingStart="#null"
android:paddingTop="#null"
android:paddingEnd="#null"
android:paddingBottom="#null"
android:progress="100"
android:progressDrawable="#drawable/circlebackg"
/>
<ProgressBar
style="?android:progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/buttons"
android:layout_centerInParent="true"
android:paddingStart="#null"
android:paddingTop="#null"
android:paddingEnd="#null"
android:paddingBottom="#null"
android:progress="80"
android:progressDrawable="#drawable/circle"
/>
<de.hdodenhof.circleimageview.CircleImageView xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/tasbih_circ_back"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/buttons"
android:layout_centerInParent="true"
android:padding="35dp"
android:src="#drawable/adkarbackground"
app:civ_border_color="#color/border"
app:civ_border_width="0dp" />
<Button
android:id="#+id/tasbih_circ_button"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#id/buttons"
android:layout_centerInParent="true"
android:background="#android:color/transparent"
android:padding="40dp"
android:text="1"
android:textSize="60sp"
android:textStyle="bold" />
<LinearLayout
android:id="#+id/buttons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/adView">
<Button
android:id="#+id/tasbih_plus"
android:layout_width="80dp"
android:layout_height="60dp"
android:layout_margin="20dp"
android:background="#drawable/adkarbackground"
android:text="+"
android:textSize="40dp" />
<Button
android:layout_width="0dp"
android:layout_height="60dp"
android:layout_gravity="center"
android:layout_weight="1"
android:background="#drawable/adkarbackground"
android:text="0"
android:textSize="40sp"
/>
<Button
android:layout_width="80dp"
android:layout_height="60dp"
android:layout_margin="20dp"
android:background="#drawable/adkarbackground"
android:text="-"
android:textSize="40dp" />
</LinearLayout>
<com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
android:id="#+id/adView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
ads:adSize="SMART_BANNER"
ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
</com.google.android.gms.ads.AdView>
</RelativeLayout>
is there any solution to remove the default padding ??
Using the current com.google.android.material.progressindicator.CircularProgressIndicator you can set app:indicatorInset="0dp" allowing you, for instance, to set a full circle as background which borders will match exactly with the progress indicator itself.
if you want to make your view little bigger than
Try Using Negative Padding like or try using scalex and scaley but use values greater than 1 in scale values. It will increase the scale of the view inside.
android:padding="-10dp"
android:scaleX="1.2"
try this in your progress bar code (xml file)
android:adjustViewBounds="true"
android:scaleType="fitXY"
view this link :
Android ImageButton crops on resize

Calendar UI not displaying properly

CalendarView not displaying properly when try to enter texts in EditText.
(softkeyboard opens , calendarview shrink)
How to set calendarView fixed height and width ?
Any custom library for Datepicker like ios ?
Layout
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#color/white"
android:layout_width="match_parent"
android:layout_height="match_parent">
<CalendarView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="20dp"
android:layout_above="#+id/im_date_edt"
android:id="#+id/calendarView"
android:layout_gravity="center_horizontal"/>
<EditText
android:id="#+id/im_date_edt"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:textStyle="bold"
android:layout_above="#+id/im_desc_edt"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/square_gray"
android:padding="10dp"
/>
<EditText
android:id="#+id/im_desc_edt"
android:layout_margin="20dp"
android:textStyle="bold"
android:layout_alignParentBottom="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="#string/Description"
android:textColor="#android:color/black"
android:textColorHint="#color/md_grey_400"
android:background="#drawable/square_gray"
android:padding="10dp"
/>
</RelativeLayout>
Check the Image.
Wrap your RelativeLayout in a ScrollView.

Height of an AlertDialog

I try to show an AlertDialog with the following code:
final int requestLayout = R.layout.triprunning_pause;
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View layout = inflater.inflate(requestLayout, null);
final AlertDialog.Builder builder = new AlertDialog.Builder(context);
builder.setTitle(R.string.runningTrip_pause_title);
builder.setIcon(android.R.drawable.ic_media_pause);
builder.setView(layout);
dialog = builder.create();
dialog.show();
The XML I'll show looks like:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="match_parent"
android:id="#+id/triprunning_pause_root">
<TextView android:id="#+id/questionText" android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="#string/runningTrip_pause_text"
android:textSize="22sp" android:gravity="center_vertical|center_horizontal"
android:paddingBottom="5dp" />
<View android:id="#+id/buttons_helper" android:layout_width="0dp"
android:layout_height="0dp" android:layout_centerHorizontal="true" />
<Button android:id="#+id/continueButton" android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="Fortsetzen"
android:layout_below="#id/questionText" android:layout_toLeftOf="#id/buttons_helper" />
<Button android:id="#+id/stopButton" android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="Beenden"
android:layout_below="#id/questionText" android:layout_toRightOf="#id/buttons_helper" />
And what I get is:
screenshot http://img546.imageshack.us/img546/2057/devicef.png
I can not really figure out, why there is this black space after the tow buttons? Any idea?
edit: get it to work with the following XML:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:id="#+id/triprunning_pause_root" android:orientation="vertical">
<TextView android:id="#+id/questionText" android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="#string/runningTrip_pause_text"
android:textSize="22sp" android:gravity="center_vertical|center_horizontal"
android:paddingBottom="5dp" />
<LinearLayout android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button android:id="#+id/continueButton" android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="Fortsetzen"
android:layout_below="#id/questionText" android:layout_toLeftOf="#id/buttons_helper"
android:layout_weight="1" />
<Button android:id="#+id/stopButton" android:layout_width="match_parent"
android:layout_height="wrap_content" android:text="Beenden"
android:layout_below="#id/questionText" android:layout_toRightOf="#id/buttons_helper"
android:layout_weight="1" />
</LinearLayout>
Not the best solutions as i got a senseless nesting but it works...
Have you tried to use android:layout_height="wrap_content" for your relative layout?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:id="#+id/triprunning_pause_root">
I use a LinearLayout to get the dialog you're going for.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/triprunning_pause_root">

Categories

Resources