Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have a TextView and I need to put a black border on the top of it.
The view is created in java, so I can't use the classic XML divider trick.
Many answers here suggest to put a black line as a background. I tried, but I found out that zooming in the view results in the line overflowing its content (in my application the views' textSizes are constantly changed by pinch zooming, so I can't know a definite width in advance.
So, my question is: is there a simple way to add a top border to a TextView which adapts to its size and which can be created from java without using XML?
Try Compound Drawables. They can be set by XML or in Code.
Use nine patch images for the Drawables or even Shape drawables and they should scale ok with the TextView.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I am working on an app and i am facing a problem about height of text view w.r.t text data.
i explain my problem with an example,
Suppose i have data like that:
String data = "In India in 1987, Khan led Pakistan in its first-ever Test series win and this was followed by Pakistan's first series victory."
and this data can easily be fit textview. But if the size of data become large like
String data = "In India in 1987, Khan led Pakistan in its first-ever Test series win and this was followed by Pakistan's first series victory,Khan led Pakistan in its first-ever Test series win and this was followed by Pakistan's first series victory."
Then is that case, the remaining part of data is not shown within the height of textView.
My question is how to dynamically increase the height of textivew for large data keeping in mind the following requirements
Text size is fixed e.g "14dp"
only size/height of textView should be increased
I have not to use the scroll view for large data, i only want to use scroll view when the size of data (eventually TextView) become large enough the size of screen, then i want to use scrollView only, to vertically scroll.
Can any one give the good solution, for this described problem. please share some snipt of code for my better understanding. Thanks in advance
You should set the height attribute of your textview to wrap_content in your xml
android:layout_height="wrap_content"
android:scrollbars="vertical"
Just make your texview scrollable:
XML Side:
android:scrollbars = "vertical"
Java Side:
Textview.setMovementMethod(new ScrollingMovementMethod());
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 5 years ago.
Improve this question
I have a kind of simple donut chart gradually colored. I want this donut be faded depending on a value. For example if the value is 35 then 35 % of my donut would be not faded and 65 % would be faded. I don't want any animation.
This is an example of what I want to achieve :
The code for the donut without the masking feature :
<ImageView
android:id="#+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:srcCompat="#drawable/donut"
android:layout_alignTop="#+id/imageView"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"/>
I don't know android designing but some web design logic may help.
Could you create a non-transparent panel over the image and give it the exact width and height of the image. So when you wish to display 20% of the image, you just giv to the panel 80% and align it properly.
Best regards.
You could also use some masking in combination with a semi-transparent image using the following steps.
create a black/white donut up to e.g. 35 %,
mask your semi-transperant with this donut (e.g. make all black parts fully transparent)
use this masked image as overlay for your full coloured donut.
This will leave you with a partly faded donut following the same contours as the original.
I am sorry I don't have any masking-code at hand, but these steps would accomplish the desired result.
This question already has an answer here:
Non-rectangular TextView
(1 answer)
Closed 8 years ago.
I have a very simple layout requirement for my Android Activity but I can't figure out how to translate it to xml: I just want the page to be filled with text (like a story, with no particular breaks at fixed places), plus an image on the upper-right corner, such that the text does not overlap with the image, but it should cover all the space which is not covered by the image. Does anybody know how to accomplish this? I tried playing around with a TextView and an ImageView, however this seems to require that the TextView occupies a non-rectangular region which I don't know how to deal with.
I'm not aware of any reasonable way to do that in a Layout.
Have you considered using a WebView and doing this in HTML?
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
How can I stretch the black to the edges? Id like to do that then put an overflow to make it a bit transparent :)
Change the dimensions in dimens.xml. By default, there is a border of 16dp around everything, so change that to 0dp. If you continue to want a border around the ListView, you can manually add the padding for that specific object by defining it in the XML layout.
Have you tried match_parent? You could also change the margins.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
someone said people must use relative layout when make android app. Because if use linear layout, app's screen doesn't adjust device screen. (I mean width and height doesn't adjust). But if I use relative layout, it's make me annoyed when I set image. Is opinion which I hear right ?
In my view i would prefer RelativeLayout as parent.
And i go for LinearLayout for all the inner layouts where i can use
android:orientation and android:height as match_parent/fill_parent that will fill only the space available with in LinearLayout.
I never prefer to use dp values for android:height and android:width
I'll go with Relative Layout as we can set different views easily in this layout.
Both have it's own pros and cons. Both can adjust without any problem to device screen. What really matter are the views that you will put inside of them (children) and how they will be organized.
In addition to that, you may want to modify the gravity, margin, padding, alignment or any other to achieve a desired result.