Is there any way to add an image to the right of Android's ListView. It needs to look similar to a type UITableView as shown in Removing the bar in standard UITableView programmatically
You can get an image to the right of the text on a row by putting the ListView, TextView and ImageView in a RelativeLayout and setting android:layout_alignParentLeft="true" for the TextView and android:layout_alignParentRight="true" for the ImageView. I have blogged about this here.
Related
I am a just a beginner to Android Studio and have started as a hobby, and to learn it's basics I have tried to make a simple calculator in Android Studio(Kotlin).
The problem is that if the answer is to long to be diplayed in the text view box it cuts out...So to solve this problem I made the text view Horizontally Scrollable using "Horizontal Scroll View" in the xml File,
But now the problem is when the user types the text after the view is full, it does not automatically scroll to the last digit he has typed, rather he/she has to manually scroll it to the end. Here is the code for the text box which displays the result:
<HorizontalScrollView
android:id="#+id/horizontalScrollView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
<TextView
android:id="#+id/tvExpression"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#1C1C1C"
android:textColor="#FFFFFF"
android:textSize="27dp"
</HorizontalScrollView>`
Could you please tell a way so that each time a new value is added to the box, it automatically scrolls to the right most part of the box, so that the users can see his/her last inputted value?
Please Help me!
Thanks,
Shaurya
Preferably delete a tag of HorizontalScrollView Because this makes textview More flexible to contain the result of the calculator.
You can also select the max line of the textView by using this attribute:
android:maxLines="select int number"
If you want a way to make the scroll of horizontalScrollView from the end
you can use this code in your activity that contents the horizontalScrollView:
horizontalScrollView.postDelayed(
Runnable {
horizontalScrollView.fullScroll(HorizontalScrollView.FOCUS_RIGHT) },
100L
)
Text View2 is visible while Text View1 isn't visible. How to resolve this problem?
There aren't enough information in the picture you posted But I guess TextView1 might cover TextView2 . In that case you may change the positions or add a function which change one's visibility to "invisible" while another is visible.
#Atul Awasthi, replace android:layout_height="200dp" for the RelativeLayout with
android:layout_height="wrap_content"
android:minHeight="200dp" and that will fix your problem.
You can see here that I have a CardView which is the parent of a ConstraintLayout.
Additionally, the CardView layout_width is set to match_parent. And the ConstraintLayout is set to match_parent. That all works because the CardView and ConstraintLayout are the width of the entire layout area.
The Problem
You can also see that I have a TextInputLayout which is the child of the ConstraintLayout. The only setting choice I have for layout_width is match_constraint (shown in following image).
When I choose match_constraint the value automatically gets set to 0dp and the widget ends up being 0dp on screen.
Is This A Bug?
Why doesn't the the TextInputLayout follow the width of the ConstraintLayout (width of entire layout) -- similar to match_parent?
Can you advise the proper way to fix this? Is there a different value that the TextInputLayout's layout_width should be set to?
You should not use match_parent for Views which are children of ConstraintLayout as stated in the documentation:
Important: MATCH_PARENT is not recommended for widgets contained in a ConstraintLayout. Similar behavior can be defined by using MATCH_CONSTRAINT with the corresponding left/right or top/bottom constraints being set to "parent".
What you're missing in your case is the end constraint for your TextInputLayout. To use 0dp (match_constraint) you need to have both constraints specified for that dimension:
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/description_layout"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
If I look at the layout's XML i see the following for the TextInputLayout
<android.support.design.widget.TextInputLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:id="#+id/description_layout"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent">
If I change layout_width like the following (by manually typing the value in):
android:layout_width="match_parent"
Then the layout looks like I expect. This seems to fix the problem. Is it correct?
I have a BottomSheetDialogFragment which is opened from another fragment.
bottom_sheet_fragment.xml:
<LinearLayout>
<TabLayout/>
<ViewPager>
</LinearLayout>
I have two fragments for the view pager each of which contains an EditText and a RecyclerView in vertical fashion.
view_pager_fragment1.xml:
<LinearLayout>
<EditText/>
<RecyclerView>
</LinearLayout>
Now when ever I click on the edit text a part of recycler view is getting hidden behind the key board.
Expected:
When ever keyboard appears the bottomsheet should scroll up so that the recycler view contents remain visible.
I've managed to achieve the behavior you want by making the root view of the BottomSheetFragment layout a android.support.v4.widget.NestedScrollView. Don't know if its going to work for you, as you seem to be using other scroll views inside.
I wanted to create ActionBar with icons in center and I made it with getSupportActionBar().setCustomView(R.layout.abs_layout);. But there problems with events. when I click to ImageView onOptionsItemSelected not working.
Where is my mistake? Can I do this other ways?
there is my code:code_files
How can I add OnClickListener to the ImageViews