This question already has answers here:
Is there an official API for centered title on Toolbar like on popular Android apps, in the new material design?
(5 answers)
Closed 3 years ago.
In my case I want to set toolbar title and subtitle in centre. I have already one solution to set custom layout in toolbar. Is that any other solution to set toolbar title and subtitle without using custom layout?
Solution 1:
<android.support.v7.widget.Toolbar
android:id="#+id/custom_toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="#android:color/holo_red_dark">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="abc"
android:textColor="#android:color/white"
android:textSize="20sp"
android:layout_marginRight="?android:attr/actionBarSize"
android:gravity="center"/>
</android.support.v7.widget.Toolbar>
I don't want to use custom layout to set toolbar title and subtitle.I appreciate your effort, in advance.
<android.support.v7.widget.Toolbar
android:id="#+id/custom_toolbar"
android:layout_width="match_parent"
android:layout_height="?android:attr/actionBarSize"
android:background="#android:color/holo_red_dark">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="abc"
android:textColor="#android:color/white"
android:textSize="20sp"
android:layout_marginRight="?android:attr/actionBarSize"
android:gravity="center"/>
</android.support.v7.widget.Toolbar>
Related
I want to make a material button having a title and subtitle
eg:- title with big text and subtitle with small text.
The Simple way is-
You can Use a Layout as a button. In the layout you can Use a Title and Subtitle and You set the SetOnClickListner on the Layout.
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:onClick="methodClick"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Title"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Subtitle"/>
</LinearLayout>
I'm trying to place 3 images on the end of the toolbar of the navigation drawer activity like this.
When using relative layout for aligning, I'm not able to see the "Home" title, I need to align three images to the right of the toolbar like this, and also I need to show the title. Where was I wrong, and how can I achieve it? The first image is what I'm expecting and second image is what I needed.
Here's what I've tried:
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/homepage_toolbar_color"
app:popupTheme="#style/AppTheme.PopupOverlay">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:layout_width="#dimen/_30sdp"
android:layout_height="#dimen/_30sdp"
android:layout_alignParentEnd="true"
android:src="#drawable/kit_icon"
android:layout_marginRight="#dimen/_80sdp"/>
<ImageView
android:layout_width="#dimen/_30sdp"
android:layout_height="#dimen/_30sdp"
android:layout_alignParentEnd="true"
android:layout_marginRight="#dimen/_40sdp"
android:src="#drawable/price_toolbar_icon"/>
<ImageView
android:layout_width="#dimen/_30sdp"
android:layout_height="#dimen/_30sdp"
android:layout_alignParentEnd="true"
android:src="#drawable/chat_toolbar_icon"
android:layout_marginTop="#dimen/_2sdp"/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>
Try adding a TextVieW near the images with the title. It should show all this way. You place this in the relative layout before the first imageview:
<TextView android:id="#+id/Txv_home"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:text="Home" />
This question already has answers here:
Searchview with back button
(2 answers)
Android SearchView customisation
(4 answers)
Custom search implementation with SearchView
(2 answers)
Android ActionBar Customize Search View
(4 answers)
Closed 4 years ago.
I want to make custom search bar layout in android. I have to attach screenshot of my design what I want to require. Check action bar design. On click action-bar search icon open custom edit-text in toolbar.
I want to make action bar layout like this.
Try this way make sure you have search icon..
<LinearLayout
android:id="#+id/llSearchContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/_5sdp"
android:background="#drawable/drawer_gredient"
android:gravity="center_vertical"
android:orientation="horizontal"
android:padding="#dimen/_10sdp">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.80"
android:background="#drawable/edittext_search_box"
android:gravity="center_vertical"
android:paddingBottom="#dimen/_2sdp"
android:paddingLeft="#dimen/_5sdp"
android:paddingRight="#dimen/_5sdp"
android:paddingTop="#dimen/_2sdp">
<ImageView
android:layout_width="#dimen/_24sdp"
android:layout_height="#dimen/_24sdp"
android:padding="#dimen/_5sdp"
android:scaleType="centerCrop"
android:src="#drawable/ic_seach" />
<EditText
android:id="#+id/lsfEtSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="#dimen/_10sdp"
android:layout_weight="0.80"
android:background="#android:color/transparent"
android:drawablePadding="#dimen/_10sdp"
android:hint="Search"
android:imeOptions="actionSearch"
android:inputType="text"
android:maxLength="50"
android:maxLines="1"
android:textSize="#dimen/_14sdp" />
</LinearLayout>
</LinearLayout>
This question already has answers here:
Inserting imageview inside edittext android
(4 answers)
How can I add an image on EditText
(10 answers)
Closed 4 years ago.
I am using the EditText with drawableLeft property and set ImageView in Left side for displaying mobile icon. My Question is how to put Imageview in EditText?
Please help me.
Actually i want like this.
I have tried using linear layout with horizontal. below is xml code.
<LinearLayout
android:weightSum="2"
android:layout_below="#id/welcome"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<de.hdodenhof.circleimageview.CircleImageView
android:layout_weight="1"
android:layout_gravity="center"
android:id="#+id/image_mobile"
android:layout_width="#dimen/_50sdp"
android:layout_height="#dimen/_50sdp"
android:src="#mipmap/ic_launcher" />
<EditText
android:layout_weight="1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/_30sdp"
android:layout_toRightOf="#+id/image_mobile"
android:hint="Mobile number"
android:inputType="text" />
</LinearLayout>
But am not able to adjust the image view and edittext.
You should use android:drawableStart
The drawable to be drawn to the start of the text.
DEMO
<EditText
......
android:drawableStart="#drawable/your_icon"
android:drawablePadding="5dp"
/>
This question already has answers here:
TextView Marquee not working [duplicate]
(20 answers)
Closed 4 years ago.
Toolbar title is too big whole title cant be seen.
Is it possible to move title right to left like marque in HTML?
it should look like animation I've seen much application with moving title. But I've no Idea how they did that.
toolbar.setTitle(""+Common.downloadsList.get(index).getName());
You can achieve your requirement like this.
These are the main properties to achieve marquee text.
android:maxLines="1"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
XML code:
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/colorPrimary"
android:gravity="center_vertical"
android:minHeight="?android:attr/actionBarSize"
app:popupTheme="#style/AppTheme.PopupOverlay">
<android.support.v7.widget.AppCompatTextView
android:id="#+id/toolbar_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:textColor="#android:color/white"
android:textSize="18sp"
android:maxLines="1"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true" />
Your Activity should look like this.
Toolbar toolbar=findViewById(R.id.toolbar);
AppCompatTextView toolbar_title = findViewById(R.id.toolbar_title);
setSupportActionBar(toolbar);
if (getSupportActionBar() != null) {
getSupportActionBar().setDisplayShowTitleEnabled(false);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
toolbar_title.setText(""+Common.downloadsList.get(index).getName());
}