This is the part from my layout
<LinearLayout android:orientation="vertical"
android:layout_height="wrap_content" android:layout_below="#id/checkBox_block_all"
android:id="#+id/linearLayout_addtoblack" android:layout_width="fill_parent">
<LinearLayout android:id="#+id/linearLayout2"
android:layout_width="match_parent" android:layout_height="wrap_content"
android:gravity="center">
<LinearLayout android:id="#+id/linearLayout3"
android:layout_width="wrap_content" android:layout_height="match_parent"
android:orientation="vertical" android:layout_weight="1">
<TextView android:id="#+id/textView1"
android:layout_height="wrap_content" android:text="Enter the full number"
android:layout_width="fill_parent"></TextView>
<EditText android:layout_width="match_parent"
android:layout_height="wrap_content" android:id="#+id/editText1"
android:textSize="18sp">
<requestFocus></requestFocus>
</EditText>
</LinearLayout>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content" android:id="#+id/button_add"
android:text="Add to black list" android:layout_weight="1"></Button>
</LinearLayout>
</LinearLayout>
and this is the image of how it looks like
The point is I want the textbox to be bigger, I set the height with value wrap_parent and I expect that the textbox will be big enough , but is not like that, the textbox as you can see is somehow cropped and I do not know why, any help , advice , anything ?, the point I do not want to set fixed values for the height of the textbox
In the "Add to black list" button, change the layout_height to "fill_parent"
The button is making the edittext smaller because their baseline is lined up
your Button is limiting the height, so either you could make layout_hieght of button to match-parent or if that looks odd, put the button in linearlayout and make the new linearlayout's height as match_parent
But I think the best way would be using a RelativeLayout and having all 3 views in the same layout
Related
I want Give paddingtop to Floating Label and set The DrawableRight Icon In Center.
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_password"
android:layout_width="match_parent"
android:theme="#style/TextLabel"
android:layout_gravity="center_vertical"
android:background="#drawable/CustomBackGround"
android:layout_height="wrap_content">
<EditText
android:id="#+id/DatePicker"
android:focusableInTouchMode="false"
android:layout_width="match_parent"
android:inputType="text"
android:paddingStart="10dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:singleLine="true"
android:text="ok"
android:textSize="14dp"
android:hint="Select Date"
android:drawableRight="#drawable/calendar_month"
android:clickable="true"
android:layout_height="50dp"
android:layout_weight="15"
android:textColor="#FF808080"/>
</android.support.design.widget.TextInputLayout>
I'm finding it hard to work out what you asking for but you can set the Drawable to: Botton, End Left, Right, Start, Top
I add 5dp padding to the image and added them for all options, like so:
<android.support.design.widget.TextInputLayout
android:id="#+id/input_layout_password"
android:layout_width="match_parent"
android:theme="#style/TextLabel"
android:layout_gravity="center_vertical"
android:background="#drawable/CustomBackGround"
android:layout_height="wrap_content">
<EditText
android:id="#+id/DatePicker"
android:focusableInTouchMode="false"
android:layout_width="match_parent"
android:inputType="text"
android:paddingStart="10dp"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:singleLine="true"
android:text="ok"
android:textSize="14dp"
android:hint="Select Date"
android:drawableBottom="#drawable/calendar_month"
android:drawableEnd="#drawable/calendar_month"
android:drawableLeft="#drawable/calendar_month"
android:drawablePadding="5dp"
android:drawableRight="#drawable/calendar_month"
android:drawableStart="#drawable/calendar_month"
android:drawableTop="#drawable/calendar_month"
android:clickable="true"
android:layout_height="50dp"
android:layout_weight="15"
android:textColor="#FF808080"/>
</android.support.design.widget.TextInputLayout>
I'm trying to animate a layout (height) placed under the toolbar and inside an AppbarLayout. I have tried several approaches to this: one of them is using ValueAnimator.ofInt and using this int to set the layout's height. This, however, is kind of choppy. According to some posts I've read, it is because requestLayout() is called in each iteration and that's an expensive operation. Almost every other option I've seen requires requestLayout() to be called. Somewhat old devices will not perform well in that case.
The other approach, which apparently is the most efficient, is to simply declare animateLayoutChanges = true in the parent layout (the AppbarLayout in this case) and simply change the height in code. This does work, but it produces and weird jump, as if the layout instantly and very breifly goes to it's final height, collapses again, and then starts animating normally. The same happens when collapsing.
In the activity, I'm simply calling setVisibility(View.VISIBLE) to expand and newTaskLayout.setVisibility(View.GONE) to collapse. I've also tried setting height to 0 and then making the view GONE to collapse, and setting height to wrap content and then making the view VISIBLE to expand, but the result is the same.
Is there any reason for this and way to avoid it? Or is there a better way to do it?
Heres the XML: (The view being animated is the COnstraintLayout under the toolbar)
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout 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"
tools:context="com.adrapps.mytasks.Views.TaskListActivity">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:orientation="vertical"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
android:title="App"
app:popupTheme="#style/AppTheme.PopupOverlay">
<ProgressBar
android:id="#+id/progressBar"
android:layout_width="30dp"
android:layout_height="30dp"
android:paddingLeft="8dp"
android:paddingStart="8dp"
android:visibility="gone" />
</android.support.v7.widget.Toolbar>
<android.support.constraint.ConstraintLayout
android:id="#+id/new_task_layout"
android:layout_width="match_parent"
android:layout_height="164dp"
android:paddingBottom="16dp"
android:paddingEnd="16dp"
android:paddingStart="16dp"
android:visibility="visible">
<ImageView
android:id="#+id/title_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="0dp"
android:layout_marginEnd="16dp"
android:layout_marginRight="16dp"
android:layout_marginTop="0dp"
android:src="#drawable/ic_label"
app:layout_constraintBottom_toBottomOf="#+id/title_edit_text"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/title_edit_text"
tools:layout_editor_absoluteX="16dp" />
<ImageView
android:id="#+id/date_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginEnd="24dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="24dp"
android:layout_marginTop="8dp"
android:src="#drawable/ic_date"
app:layout_constraintBottom_toBottomOf="#+id/date_edit_text"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="#+id/date_edit_text"
app:layout_constraintVertical_bias="0.333" />
<ImageView
android:id="#+id/notification_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="16dp"
android:layout_marginLeft="0dp"
android:layout_marginRight="16dp"
android:layout_marginTop="28dp"
android:src="#drawable/ic_notifications_none_black_24dp"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="#+id/date_icon"
app:layout_constraintTop_toBottomOf="#+id/date_icon" />
<EditText
android:id="#+id/title_edit_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:hint="#string/task_title_hint"
android:textAppearance="#style/TextAppearance.AppCompat.Small"
app:layout_constraintLeft_toRightOf="#+id/title_icon"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toEndOf="#id/title_icon"
app:layout_constraintTop_toTopOf="parent" />
<EditText
android:id="#+id/date_edit_text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginTop="12dp"
android:hint="#string/task_due_date"
android:textAppearance="#style/TextAppearance.AppCompat.Small"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toRightOf="#+id/date_icon"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toEndOf="#id/date_icon"
app:layout_constraintTop_toBottomOf="#+id/title_edit_text" />
<android.support.v7.widget.AppCompatSpinner
android:id="#+id/notification_spinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="8dp"
android:layout_marginStart="6dp"
android:entries="#array/notification_options"
app:layout_constraintBottom_toBottomOf="#+id/notification_icon"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toRightOf="#+id/notification_icon"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="#+id/notification_icon" />
</android.support.constraint.ConstraintLayout>
</android.support.design.widget.AppBarLayout>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="#dimen/fab_margin"
android:src="#drawable/ic_add_black_24dp" />
<include layout="#layout/content_main" />
</android.support.design.widget.CoordinatorLayout>
I want to make a nice Main Menu Page like the home page of Android Device in which the button images are layout in rows; each row in a page say contain 4 imageButtons.
I used the below layout, but the imageViews in each rows are not evenly size. I have these questions:
I want to have 3 imageView in a row.
How to detect What is the Width and Height of a screen, so divide it for 3 imageView? say, base on galaxy note.
How to do spacing among the 3 imageViews? Below each ImageView there is a textView to indicate the name or function of the ImageView.
Should I allow rotate? if rotate , how to enable scrolling when rotate to horizontal?
Thanks
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/myLinearLayout"
android:minWidth="25px"
android:minHeight="25px">
<LinearLayout
android:orientation="horizontal"
android:minWidth="25px"
android:minHeight="25px"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toRightOf="#id/poiImageView"
android:id="#+id/linearLayout1"
android:layout_centerVertical="true">
<ImageView
android:id="#+id/Thumbnail1"
android:layout_width="70dp"
android:layout_height="70dp"
android:paddingLeft="10dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="#drawable/Icon" />
<ImageView
android:id="#+id/Thumbnail1a"
android:layout_width="70dp"
android:layout_height="70dp"
android:paddingLeft="10dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="#drawable/Icon" />
<ImageView
android:id="#+id/Thumbnail1b"
android:layout_width="70dp"
android:layout_height="70dp"
android:paddingLeft="10dp"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:src="#drawable/Icon" />
</LinearLayout>
<LinearLayout>
2nd row
</LinearLayout>
<LinearLayout>
3rd row
</LinearLayout>
</LinearLayout>
I believe you're looking for GridView. GridView is a ViewGroup that displays items in a two-dimensional, scrollable grid. It handles scrolling by itself when content grows. Additionally you will get additional features packed such as memory handling, inbuilt MVC using adapter pattern etc.
A simple GridView looks as follows;
<GridView
android:id="#+id/gridView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:columnWidth="100dp"
android:drawSelectorOnTop="true"
android:gravity="center"
android:numColumns="auto_fit"
android:stretchMode="columnWidth"
android:verticalSpacing="5dp"
android:focusable="true"
android:clickable="true"/>
You can checkout some complete GridView implementation from the following links.
Android GridView Example- Building Image Gallery in android
Download and Display Image in Android GridView
Here is my layout xml file
<?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" >
<RadioGroup
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="true"
android:text="男" />
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="女" />
</RadioGroup>
</LinearLayout>
the result is that both radiobutton have been checked
how to fix it?
and if I change the LinearLayout to TableLayout,waht other questions should I notice?
I finally get it after many tests!!
The conclusion is: In a RadioGroup,if a RadioButton is set checked="true",you
must give the RadioButton an id (android:id="#+id/name"); If not, the status will not change to disselected with the "checked radiobutton" when you select other radiobutton.
So,don't forget add an id to the radiobutton!
but I don't know how the source code works?
I am stuck at gridview.
I want an imageview below Gridview to handle click event of that.
Basically what i need is when click on this imageview button(here imageView_uparrow) it will slide up the layout which contains this gridview,
but when I add imageview(imageView_uparrow) below gridview(imageView_uparrow) in xml and run the project; gridview repeats that imageview on every grid icon.
I want that imageview to be appeared once at the bottom. Here is my XML.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top" >
<GridView
android:id="#+id/inside_gridView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:layout_marginTop="58dp"
android:alpha="0.1"
android:background="#696969"
android:columnWidth="10dp"
android:gravity="center"
android:numColumns="3"
android:padding="4dp"
android:scrollbars="vertical"
android:stretchMode="columnWidth" >
</GridView>
<ImageView
android:id="#+id/image_insidegrid"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_margin="5dp"
android:contentDescription="#string/hello_world" />
<ImageView
android:id="#+id/imageView_uparrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="22dp"
android:layout_marginRight="20dp"
android:contentDescription="#string/hello_world"
android:src="#drawable/drop_down_top_arrow" />
</RelativeLayout>
Last imageview i.e imageView_uparrow keep on repeating with the gridview items.
Please help me with this.. Thanks in advance.!
Hey I got the solution..
i kept my imageView_uparrow in separate xml and image which i used to set as an icon of my grid separate xml.And just inflated and added that to the Layout.
My modified Grid Xml is here
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_gravity="top"
android:id="#+id/parentRel"
>
<GridView
android:id="#+id/inside_gridView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="50dp"
android:layout_marginLeft="14dp"
android:layout_marginRight="14dp"
android:layout_marginTop="42dp"
android:background="#drawable/transperant_background"
android:gravity="center"
android:numColumns="3"
android:padding="0dp"
android:scrollbars="vertical"
>
</GridView>
</RelativeLayout>
This is my xml file for ImageView(imageView_uparrow).
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout_up_arrow_for_gridView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<ImageView
android:id="#+id/imageview_up_arrow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="14dp"
android:contentDescription="#string/app_name"
/>
</RelativeLayout>
Code i use to inflate
Context context;
RelativeLayout rel;
ImageView upArrowImage;
LayoutInflater inflator = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
context=this;
View grid2;
rel=(RelativeLayout)findViewById(R.id.parentRel);
animate = AnimationUtils.loadAnimation(this, R.anim.slide_up);
animate.setAnimationListener(this);
LayoutParams lp = new LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
lp.setMargins(14, 400, 0, 20);
grid2=new View(context);
grid2=inflator.inflate(R.layout.gridview_up_arrow_button,null);
upArrowImage=(ImageView)grid2.findViewById(R.id.imageview_up_arrow);
((ViewGroup)upArrowImage.getParent()).removeView(upArrowImage);
rel.addView(upArrowImage);
upArrowImage.setImageResource(R.drawable.drop_down_arrow4);
upArrowImage.setLayoutParams(lp);