android button 行间距,android – 如何减少TextView行间距
我試圖通過設置TextView.setLineSpacing()的負“添加”來減少TextView中的行間距.除了底線被截斷之外,它運行良好.
主要布局
android:id="@+id/text_view"
android:padding="dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
tools:context=".MainActivity" />
主要活動:(注意
package com.font_test;
import android.app.Activity;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final Typeface typeface = Typeface.createFromAsset(getAssets(),"fonts/custom_fonts.ttf");
final TextView tv = (TextView) findViewById(R.id.text_view);
tv.setTypeface(typeface);
tv.setTextSize(60);
tv.setLineSpacing(-30f,1f); // *** -30 to reduce line spacing
tv.setBackgroundColor(0x280000ff);
tv.setText("gggkiiikkk" + "\n" + "gikgikgik" + "\n" + "kigkigkig");
}
}
這導致在視圖底部截斷(注意底線的’g’):
似乎問題與錯誤的布局測量有關.如果我將TextView設置為
android:layout_height="fill_parent"
它確實正確呈現:
知道怎么解決嗎?如果它有幫助,我不介意有丑陋的變通方法.我也可以訪問FontForge,如果需要我可以修改字體文件.
總結
以上是生活随笔為你收集整理的android button 行间距,android – 如何减少TextView行间距的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: ZZULIOJ 1064:加密字符
- 下一篇: 最大堆java构建,jvm - 无效的最