Set visalbe border to matrix in XML - java

I have a matrix-like structure. Each row is a LinearLayout of n-TextViews. Both are created programmatically and added to a LinearLayout "container". In XML:
<LinearLayout
android:id="#+id/container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
</LinearLayout>
This is how it looks in App after building a matrix at runtime:
I always want to add a border to first/last column as well as to the first and second row, for each mxn-matrix. I want it to look like this:
I think the border / frame has to be added programmatically as well.
So my approach would be something like building a TableLayout as container and replace the LinearLayouts for each row with TableRows.
After that set the background color of TableLayout to black and give every needed TextView a padding on the right place programmatically.
But this seems to be a very stressful task. So I really hope there is a better way to do that.
I am using Kotlin.
I am very thankful for every suggestion!

Related

How to put security patch on Text view?

I don't know what to say to this but I want mask or put patch on Text view.
See the picture below. I want effect like this. I've searched lot but didn't find any post with same requirement. How to achieve this?
You can pass two images in one TextView Like below Code:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/icon"
android:drawableRight="#drawable/pacth_icon"
/>
use
android:drawableLeft
and
android:drawableRight
to set your images in TextView.And you can setText and background Image as well.

Android: ListView with left status line

Need something like this: ListView and Status Line
Please could you suggest the best way to do this?
add for each row - line which be stretched over the whole height (and half for first and the last item), or a separate element?
Or maybe there already some library?
Just make a View as a line.
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:background="#45a"
android:id="#+id/line"/>
and you can animate this view according
Yeah, 3 different layouts would be the best choice, 1° element with the line stretching only in the second half, middle elements with full line stretch (both top and bottom) and the last element with only top line. You need to check the position in which you're inflating the layout, and inflate the correct one of your choice!

optimizing screen from phone size to tablet size android development

I am fairly new to java and android. at the moment i am studying java at school. i just started working in this calculator just to get my hand in android developing. my problem at the moment is that when i deploy the app to the emulator (phone size 480x800) looks like Pic 001, but when i deploy it to my Kindle fire 1st gen (1024x600 i believe) looks like Pic 002. how can i make it so it look the same in every phone.
XML File
In order to have your buttons fill the entire width of your screen, put this in your tags Button:
android:layout_width="0dp" android:layout_weight="1"
instead of :
android:layout_width="80dp"
If you want the buttons to be higher :
- In your tags Button change android:layout_height="80dp" to android:layout_height="match_parent".
- In your tags LinearLayout which contain your buttons change android:layout_height="wrap_content" to android:layout_height="0dp" android:layout_weight="1".
- In your tag TextView change android:layout_height="wrap_content" to android:layout_height="0dp" android:layout_weight="X" where X is the value that gives you the right proportions.You will have a warning telling your that nested weight are bad for performance but it's the only way I know to do this.
In general, if you want a component to fill the empty space, set the width or height to 0dp and add a weight. The weight will define the proportions of the elements which want to fill the space.
I hope it will help you.

Android - Creating a dynamic TextView

I am creating an Android game and have an issue with dynamic text with a TextView. Essentiall within my layout, I have a TextView, within a Relative Layout with enough space for several lines.
What I would like to do is add 5 lines within the TextView, with a functionality that once it is trying to write a 6th line it automatically overwrites line 1, therefore only ever showing a max of 5 lines of text.
Example of What I am after:
dynamic line 1
...
dynamic line 5
Please find below my xml code:
<RelativeLayout android:id="#+id/battleconsole"
android:layout_width="fill_parent"
android:layout_height="135dp"
android:gravity="center_horizontal"
android:layout_below="#+id/spacer1" >
<TextView
android:id="#+id/battle_details"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:text="Console with information" />
</RelativeLayout>
This is the code that I am using to update the text within the TextView:
TextView update = (TextView)findViewById(R.id.battle_details);
update.setText("test console data going in here");
I am not sure if this is even possible using a TextView, if not is there any other way I can solve this issue?
Thanks in advance
Keep the 5 lines in a collection (array or list). When you set the text on the TextView, join the lines in the collection on "\n". Then just replace the item in the collection with the updated text.
Android has a join method in the TextUtils class, but I prefer the Guava library's Joiner class. Check it out: Google Guava

ListView checkboxes are over text, how to pad text and force checkbox standard color?

I have a listview checkboxes with text in a Linear Layout:
<CheckBox android:layout_width="fill_parent"
android:layout_height="wrap_content" android:id="#+id/nomeAPP" style="?listItem" />
But those checkboxes are over the text.
There's any way to pad the text a little to the right?
Also, I was testing with a AVD with 2.2 SDK. Just tested on my phone (also on 2.2), but looks like because of the phone theme (i have a cooked rom) the checkbox color is white (instead the standard grey). Is anyone way to force the checkbox color to the usual grey?
Try using the padding attribute i.e android:paddingRight to apply padding to text towards right.Please refer this link.

Categories

Resources