Reputation: 1628
I am developing apps in android. I did design for TextView in my apps see image 1
This is my xml code
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/img"
android:gravity="center"
android:scaleType="fitXY"
android:text="Recommend Outlet"
android:textColor="#ffffff"
android:textSize="16sp"
android:textStyle="bold" />
I want TextView style like following image
The Value of 2 with Recommend Outlet is dynamically set from json Object.
TextView tv = (TextView) findViewById(R.id.tv);
tv.setText("Recommend Outlet " + cus_recommend);
tv.setTextSize(10);
How can I set Outlet Text Below Recommend Outlet..? Does anybody have solution ?
Upvotes: 0
Views: 347
Reputation: 9700
add android:singleLine="false"
attribute to your TextView
XML as below...
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/img"
android:gravity="center"
android:scaleType="fitXY"
android:text="Recommend Outlet"
android:textColor="#ffffff"
android:textSize="16sp"
android:textStyle="bold"
android:singleLine="false" />
and then add new line operator (\n
) as below...
TextView tv = (TextView) findViewById(R.id.tv);
tv.setText("Recommend Outlet \n" + cus_recommend);
tv.setTextSize(10);
Upvotes: 4
Reputation: 1425
Make the text two lines. If the first is stagnant then put the dynamic one underneath. Don't forget to rename it your Activity.
<TextView
android:id="@+id/tv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:background="@drawable/img"
android:gravity="center"
android:scaleType="fitXY"
android:text="Recommend Outlet:"
android:textColor="#ffffff"
android:textSize="16sp"
android:textStyle="bold" />
<TextView
android:id="@+id/json_data"
android:layout_below="@id/tv" />
Upvotes: 0