Linked Questions
13 questions linked to/from Android and setting width and height programmatically in dp units
3 votes
3 answers
14k views
Setting height of TableRow [duplicate]
I have two types of content for TableRow. One has two lines and the other one. I wish everyone had the same height. I'm trying something like this: tr.setLayoutParams(new TableRow.LayoutParams(...
1 vote
1 answer
477 views
Dynamic horizontal progressbar width not showing full width in android [duplicate]
I am creating dynamic progressbar width but it's now showing properly. When i set width (272 dp ) in xml it's showing properly but i am setting same width programmetically it's not showing correct ...
134 votes
9 answers
71k views
how to get android screen size programmatically, once and for all?
How can I find out my screen size programmatically, in the units used by touch events and View measurement/layout? In other words, I want the coordinates of the bottom-right corner of the screen, in ...
31 votes
7 answers
58k views
How can we set height and width dp for imageview in android?
I would like to set height and width in dp for ImageView in android pragmatically. How can I achieve this?
13 votes
5 answers
7k views
Android AutoCompleteTextView popup moving after displaying
When I use the autocompletetextview everything works fine except it keeps switching between two positions: the correct one right below the textview and quite a ways lower. It starts wrong, but almost ...
3 votes
3 answers
6k views
How to set the width of a button in dp during runtime in android?
I have an android application. There are a lot of buttons in it but these buttons are created during runtime. If i set the width button.setwidth(300) it will set the width to 300px. I want the width ...
2 votes
4 answers
5k views
Custom passwordToggleDrawable is too large in TextInputLayout
I have used android.support.design.widget.TextInputLayout to make a password input that allows the user to toggle readability on the password. The xml is as follows: <android.support.design.widget....
0 votes
2 answers
1k views
how to change stroke color in android by kotlin code?
i want to change border color for imageview manually in kotlin. val backgroundGradient = imgIcon.getBackground() as GradientDrawable backgroundGradient.setColor(getResources().getColor(R.color.yellow)...
1 vote
0 answers
197 views
Is there any way to get the actual height of recycler view?
I have layout which includes some button, textviews and a recyclerview. The layout already has a scrollView, so i disabled scroll of recyclerView. Now i want to set the height of recyclerView ...
0 votes
1 answer
87 views
Creating multiple views
I am trying to inflate a view multiple times. my view consists of one imageview and a textview below it and placing it at particular position. Below is my item.xml which I am inflating multiple times:...
0 votes
1 answer
53 views
Storing and initializing universally used values for an android App (example: Screen density)
I'm pretty new to programming for Android so if this is the wrong way to go about it anyway, feel free to comment about my bad practice. In my App, I have different Activities that use the same values....
2 votes
0 answers
58 views
Unit in Changing RelativeLayout Programmatically
I tried to change RelativeLayout's height programmatically, that is using Java. I have the following code: RelativeLayout rl = (RelativeLayout) findViewById(R.id.center); rl.getLayoutParams().height =...
0 votes
0 answers
45 views
android customView size is not working correctly
I've created a custom view that should draw a star using these points: float [] mPoints = {0, 100, 75, 75, 75, 75, 100, 0, 100, 0, 125, 75, 125, 75, 200, 100, 200, 100, 125, 125, 125, 125, ...