I wanted to implement the android default button click effect on a Relativelayout. (The material design one)
But the problem is that it works on a view like TextView, But it's not working on a RelativeLayout(I want the relativelayout to have the android default button click effect , just like a normal button ).
I have used :
style="?borderlessButtonStyle"
and
style="?buttonStyle"
But none of them seem to work. They both work on a TextView but not on a Relativelayout. Any thoughts ? Any help is greatly appreciated.
Add this to your layout:
android:background="?android:attr/selectableItemBackground"
Have you added a not null OnClickListener to your RelativeLayout?
And make sure that the layout is clickable with (in xml):
android:clickable="true"
or, in code:
relativeLayout.setClickable(true);
Related
I have a recyclerview that I would like to share the same background as the activity so that only the textviews inside the recyclerview are visible. I've tried things like this in the cardview and recyclerview xmls:
android:background="#android:color/transparent"
and
android:background="#null"
They haven't worked. Is this possible? I haven't found any answers in previously asked questions on here that have been successful. Any ideas appreciated!
Cardview is for beautifying layout and giving shadow to it, If you don't want to use this feature than you should avoid CardView and use simple LinearLayout, RelativeLayout, ConstraintLayout etc. and than give transparent background to it.
But still you want to use CardView, remove this line
android:background="#android:color/transparent"
and add this line to your CardView.
app:cardBackgroundColor="#android:color/transparent"
If you are using fragment, you need to add it on your container instead of replacing it:
supportFragmentManager.beginTransaction().add(YourFragment(),"tag").commit()
I am beginner in android animations and therefore, am wondering exactly how can I implement something like expand a cardView to show hidden options or elements.
For example: a post in social networking, we have a cardView holding the post info. it also has likes and comments buttons/options. When user taps on comments button the view should expand a little say certain height and show the comments and shrink back when the same button is tapped again.
I am listing my posts using RecyclerView in a Fragment using a CardView. I am looking for a soft animation along with expanding and shrinking back to original place or size.
Below is a screenshot that might help you understand what exactly I want:
How to do this? Will you please provide me a small snippet of code?
use wrap content as height of cardview and use textview inside it below title, so on click make the textview visible and invisible.
And use android:animateLayoutChanges="true" in parent layout.
Was wondering how you would go about implementing a custom layout for a toolbar popup, the one you get when you press on the settings button.
I need to increase the padding on the top and bottom of the popup, and also add in a custom font here. The only way I can think to do it would be to basically inflate a custom layout here but I'm not sure how it can be done. Most of the documentation I find online about it is just about styling it instead of adding in a new layout.
I thought maybe doing something like:
app:actionLayout="#layout/menu_settings_popup"
Would work, but unfortunately it doesn't. Also trying to set the layout and background in styles didn't
Would appreciate any help with this. Thanks
I think this would be what you need:
https://scriptedpapers.com/2015/02/12/android-action-bar-and-overflow-menu-customization-with-theme-appcompat/
I want to create a settting UI like this in android:
Questions:
How to create the layout? I believe it's a Vertical LinearLayout containing some of TextView with Divider set, is that right?
How to create sub-textview? (see the image above)
How to create a checkbox which aligned at right? (again, see the image above)
Look at the image above, the "Keypress popup" can be clicked and it will show up a dialog. How to create a clickable TextView? I have tried giving android:onClick on the TextView, but nothing happened when I clicked the TextView.
PreferenceActivity will help you to implement all these very easily. Go through this and this tutorials.
PreferenceFragment should be used post Honeycomb.
I'm a beginner Android developer and I'm making my first app. I'd like to make a simple view that is overlayed on the map with a semi-transparent background. This is what it would hopefully look like:
As you can see, one of these dialogs/windows has a simple integer displayed and the other will have a rendered graph/chart.
What would be the best way to go about making this? A dialog? The problem with that might be that I would for the user to be able to work with the mapview below while this is displayed. And I'm not sure if a simple transparent rectangular canvas is the right way to get this done.
Any suggestions/ideas would be much appreciated. Thanks so much.
two ways to go
-Make it a FrameLayout so add MapFragment first then add a Linearlayout with orientation horizontal and make gravity top and translucent background,so it will be displayed on top of map, and it will also involve the elements inside,
-Instead of FrameLayout make it a RelativeLayout and the same process as above.
-Make the overlay as seperate Activity(which is the worst case scenario)
Sample code for overlay can be like this
<LinearLayout
....
android:divider=".." // some drawable or color whatever you want
android:showDividers="middle"
android:orientation="horizontal"
android:background="a000">
<TextView
....
android:value="58"/>
<com.example.custom.view
..../>
</LinearLayout>
I think you can use a RelativeLayout on the top of the MapFragment, with a black background and some opacity (for that you can use a drawable).
Then, on the RelativeLayout you can add other controls like TextView and ImageView
I don't recommand you to use a Dialog, since it sounds like it's not corresponding to your needs.