Organise views/buttons after changing the font (setting->display->fontsize) - android

The layout has just two buttons in a linear layout and it looks like the following when the font size is default (setting->display->fontsize).
Now if I change the font to bigger size, it becomes to
But I would like to show the following
I wrote a custom linearlayout and tried to manipulate the layout's parameters based on the linecount in onLayout function. Most of the time it works well. However if the layout is part of nestedscrollview, it starts flickering.
Any suggestion or help would be appreciated. Thanks

Related

Change the opacity/transparency of a view and affect the child views too

I have a relative layout with child TextViews.
The background of the parent RelativeLayout is white and I was wondering how I could change the alpha to change the opacity of the whole view programmatically (including children).
I am trying:
getBackground().setAlpha(0.4);
But that expects an int and not a float.
If I do:
getBackground().setAlpha((int)(0.4 * 255));
The latter changes the view but makes it darker than I want. Also the children do not seem to change. It seems to affect only the background while I want something that makes everything more "grayed" out/less transparent.
What am I doing wrong?
Have you tried using android:background="#88000000" in layout file. You can change alpha and color values as required.
That's because you are changing the backgound of the layout and not the layout itself. So instead of myRelativeLayout.getBackground().setAlpha(), use this: myRelativeLayout.setAlpha(0.4f).

Linear Layout baselinealigned warning on android

i am getting "Set android:baselineAligned="false" on this element for better performance" while using LinearLayout, I know its regarding performance,but i dont know exactly why it is,please clarify me
If you are looking for a visual explanation like me, then you might find this useful.
When baselineAlign is enabled(i.e if it is set to true), then all the text in that line will be aligned to have the same baseline.
Note: By default, baselineAligned is set to true. (i.e. baselineAligned=true)
When you make baselineAligned=false, all it needs to do is to add new elements to the linear layout and be done with it. The app need not worry about where the baseline of other elements in the layout is.
See the image below for more clarity
android:baselineAligned/setBaselineAligned(boolean): When set to false,
prevents the layout from aligning its children's baselines.
So can take example with linear layout with horizontal child views having multiple TextView with different text size or different views like button there basealignment would be different and you cannot adjust it to have same basealignment if you set it to false
Reference
Update:
By setting android:baselineAligned="false" , you're preventing the extra work your app's layout has to do in order to Align its children's baselines; which can obviously increase the performance. (Less unnecessary operations on UI => Better performance) as mentioned here

How to add TextView at below in a RelativeLayout when there is no space at right?

I've seen many of questions for how to add TextView in a RelativeLayout programatically, but everybody adding it in LinearLayout with orientation vertical. Can any one suggest me or give me a link that how to add multiple TextView in RelativeLayout at right until it has space and then change the line.
I want a layout like this..
May be this works for you !
You can customize chips-edittext-library for your need. Customizing by setting background to transparent, and editable to false.
-> Or you can use any other library which is used for displaying emoticon in EditText and customize it according to your need. Like android-emoticon-edittext-spike
You can use the Flow Layout library that manages the view arrangement itself.
When there is no space left the added View is moved to the next line

Scrollview stretches background Android

I have read many question on this topic but found no answer.
the problem is that I have a ScrollView as mainView in my xml and if I set a background it is stretched.
ScrollView(background)-->content
I also tried:
Scrollview-->content(background)
To solve the issue I need to wrap the scrollView inside a LinearLayout.
LinearLayout(background)-->ScrolView-->content
Now the background (if applied to the mainLinearLayout) is no more stretched but I have the warning:
This ScrollView layout or its LinearLayout parent is possibly useless; transfer the background attribute to the other
view
I'd like to have the background not stretched and also get rid of this warning.
Probably I've not fully understood how this Views work...
Thanks for your help
Not a beautiful answer. But it should work.
You can set the background activity in styles xml file.
Remove useless LinearLayout.
Set the background of scrollview to transparent.
in your first case, use android:layout_height="wrap_content" for the scrollview and it won't stretch the background picture anymore

How to keep EditText from breaking to the next line when width does not match_parent?

I am trying to fit two EditTexts horizontally. What I am trying to accomplish is make the text keep scrolling right without the EditText extending in anyway when there is no more space in that specific EditText. This happens when the EditText is set to match_parent (width), but when I set an actually width or wrap_content, it breaks to the next line. Not the behavior I am hoping for. Any ideas?
If I understood your question correctly, you're saying you want the edit text to be a single line each? If so, have you tried using the xml attribute
android:singleLine
Or you can accomplish the same thing with:
setSingleLine() //called on the edit text
I just tested it out with 2 edit texts in a horizontal linear layout set to 100dp width each and I think it accomplishes the behavior you want.
You can try this:
Set both to fill_parent and layout_weight=1. This will align them side by side.

Categories

Resources