Possible to change the spacing around MaterialCheckBox? - android

I'm curious to know whether it's possible to change the default spacing that's placed around MaterialCheckBox... or whether there are plans to allow for this.
Let's say, for the sake of example, I have a CheckBox defined with four TextViews around it (to the left, right, top and bottom of it) and I specify no margins on any of the five Views. If I define my app's theme as Theme.AppCompat.Light then this CheckBox is rendered with equal spacing around it as follows:
If I change the app's theme to Theme.MaterialComponents.Light and make no other changes to the app then the CheckBox is rendered as follows:
Note the unequal spacing which I would like to customise on a per-need basis. There's nothing mentioned in the MaterialCheckBox documentation and I can't see anything obvious in the class definition about being able to change this spacing.
(For what it's worth I'm using the latest version of the com.google.android.material:material library, i.e. 1.1.0-alpha03. And everything I've said above holds regardless of whether I define a CheckBox, AppCompatCheckBox or MaterialCheckBox in my layout. The key thing is changing the theme from Theme.AppCompat.Light to Theme.MaterialComponents.Light.)

This looks related to MaterialCheckBox enforcing a 48dp minTouchTargetSize for accessibility using android:minWidth in the CheckBox style (this should be added to the documentation). Setting android:minWidth to 0dp should work.

Related

AutoSizeTextType uniform doesn`t work for custom text view in Xamarin.Android

I want to automatically scale font size depending on contents in Xamarin.Android app in custom class. Scaling works for TextView. But when I use NoobTextView scaling does not work.
In the original TextView, the autosize attributes refer to the android: namespace. And in it, auto-size only works on the latest versions of the droid. Attributes from app: are only picked up by appcompat versions. Judging by the fact that now it works in this form - I have an AppCompat or Material theme installed, in which, during inflate, an AppCompatTextView or MaterialTextView is created instead of a TextView. Accordingly, no substitution occurs for custom TextViews. The solution is to inherit from AppCompatTextView.

Certain Options Missing in Android Studio

enter image description here
Absolute beginner here, and I can't seem to access all of my options in android studio. For example, when I put in a textview in the layout, for the layout_width, fill parent option is not appearing, even though I definitely remember it to have been there when I used in briefly on my friend's computer.
It's not there as it's not an optimal option:
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".
(source)
maybe you saw that option on a different layout (eg. linear).

Android button size changing

I have two buttons in my layout. They appear fine with padding around their sides. However, when I change the activity's theme to #android:style/Theme.Black.NoTitleBar
All of a sudden, the buttons become really small with no padding around them. Why is this happen? All it takes is for me to remove the theme attribute (remove NoTtitleBar) and that fixes them. What does that have to do with the buttons?
Need to use
android:theme="#android:style/Theme.Holo.NoActionBar"
instead. The one I was using before is for gingerbread and so it changes the default style of buttons, etc...

Default view padding

I'm just starting to learn android and i had a doubt concerning to view padding. Referring to What controls the default padding between views? , Is the padding included in the size we specify to the view ? All help appreciated!
EDIT: Also does a layout add padding to itself by default ?
In the question you linked to, the padding is caused by the button's background being a nine-patch and having some transparent borders in it. Since the "padding" is part of the background resource, it is include in the image size and you don't need to do anything to make it show up.
However, if you are creating your own Views, or changing the background or foreground resources of the system provided Widgets, you may want to use the android:padding* attributes to specify the various paddings.

Referencing an individual style attribute from layout xml?

Is it possible to do something like the following?
<LinearLayout android:id="#android:id/empty"
android:background="?android:style/Widget.ListView.overScrollFooter"
>
Left out all the unimportant layout stuff. I'm wondering if it's possible to reference one of the individual attributes of defined in a style?
Edit for more info: The default styles and attributes for many widgets are defined by Android, and customized further by phone manufacturers. That's how they can customize how a basic android widget looks. In my example, the footer of a listView will look different on a Samsung phone than on a HTC phone or on a default Google phone.
I would like to grab the attribute defined in the listview style (specifically the overscrollfooter drawable attribute), and use it as a background for one of my views. Technically speaking, I have a programmatic solution for this, but it's clunky, and requires that I repeat that code every time I use this view (which is in a lot of places).
No, I think a style is an all or none kinda of deal. I would place the footer in it's own style and import it into your primary style. That frees it up to be used (alone) in yout LinearLayout.

Categories

Resources