开发者

textview multiline problem

开发者 https://www.devze.com 2023-03-15 01:06 出处:网络
I am having two textviews in my linear layout i am facing the below visibility there Hiasdf asdf asdf asdf

I am having two textviews in my linear layout i am facing the below visibility there

Hi    asdf asdf asdf asdf
      asdf asdf asdf asdf
      asdf asdf asdf asdf
      a开发者_运维知识库sdf asdf asdf asdf

here "Hi" is one textview and "asdf..." is one textview. But i want the visibility like below

Hi    asdf asdf asdf asdf
asdf asdf asdf asdf asdf
asdf asdf asdf asdf asdf
asdf asdf

So the second textview should start from the starting of the parent layout and not after the end of first textview. Any suggestions would be really helpful in my learning of android?


Please append both textview value and then display in third textview so may be solved your visibility like that.


Not a good Idea but worth trying, try using the below xml with the help of Framelayout you can achieve this, Also add your Idea to improve it, Here just append some space for the text in second text view to make it look apart from first text view.

<FrameLayout android:orientation="horizontal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:background="#FFFFFF">    
<TextView 
     android:id="@+id/ID1"
     android:text="HI"  
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:textColor="#00529b">
     </TextView>
<TextView 
     android:id="@+id/ID2"
     android:text="      Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello Hello "  
     android:layout_height="wrap_content"
     android:layout_width="wrap_content" >
     </TextView>
</FrameLayout>


You can salve this set the text as HTML in your TextView.

for ex

myTextView.setText(Html.fromHtml("<h2>Title</h2><br><p>Description here</p>")

There are some more utility classes available to do linking and much more

http://developer.android.com/reference/android/text/util/Linkify.html

Check example for this http://jtomlinson.blogspot.com/2010/03/textview-and-html.html

0

精彩评论

暂无评论...
验证码 换一张
取 消