Reputation: 9544
One of my TextView is taking extra space
even though there isn't any padding or margin attached with it. As you see in below picture
TextView xml code
<TextView
android:id="@+id/txt_bundle_change_percentage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:alpha="0.6"
android:fontFamily="@font/suisse_intl_semi_bold"
android:text="14.92%"
android:textColor="@color/bundleScreenTextColor"
android:textSize="@dimen/_12ssp" />
layout xml file which contains the TextView
<LinearLayout
android:id="@+id/bundle_change_percentage_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="end"
android:orientation="vertical">
<LinearLayout
android:id="@+id/bundle_change_percentage_value_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/txt_bundle_change_percentage_icon_up"
android:layout_width="@dimen/_9sdp"
android:layout_height="@dimen/_8sdp"
android:layout_gravity="center_vertical"
android:alpha="0.6"
android:src="@drawable/ic_value_up"
android:tint="@color/bundleScreenTextColor"
android:visibility="visible" />
<ImageView
android:id="@+id/txt_bundle_change_percentage_icon_down"
android:layout_width="@dimen/_9sdp"
android:layout_height="@dimen/_8sdp"
android:layout_gravity="center_vertical"
android:alpha="0.6"
android:scaleY="-1"
android:src="@drawable/ic_value_up"
android:tint="@color/bundleScreenTextColor"
android:visibility="visible" />
<TextView
android:id="@+id/txt_bundle_change_percentage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:alpha="0.6"
android:fontFamily="@font/suisse_intl_semi_bold"
android:text="14.92%"
android:textColor="@color/bundleScreenTextColor"
android:textSize="@dimen/_12ssp" />
</LinearLayout>
<TextView
android:id="@+id/txt_bundle_change_percentage_heading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:alpha="0.6"
android:fontFamily="@font/suisse_intl_regular"
android:text="@string/txt_24h_price_change"
android:textColor="@color/bundleScreenTextColor"
android:textSize="@dimen/_9ssp" />
</LinearLayout>
Upvotes: 2
Views: 650
Reputation: 223
Please update this code. it will work.
<TextView
android:id="@+id/txt_bundle_change_percentage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:height="24dp"
android:alpha="0.6"
android:text="14.92%"
android:textColor="@color/colorAccent"
android:textSize="24sp"
android:background="@color/colorPrimary"
android:includeFontPadding="false"
android:layout_marginTop="-5dp"
android:layout_marginLeft="-2dp"
/>
Upvotes: 0
Reputation: 2525
when u need closer add this to align text to the top
textView.setGravity(Gravity.TOP);
Upvotes: 0
Reputation: 485
setIncludeFontPadding (boolean includepad)
or in XML this would be:
android:includeFontPadding="false"
Upvotes: 3