【问题标题】:Justify android text inside a textview without using a WebView在不使用 WebView 的情况下在 textview 中对齐 android 文本
【发布时间】:2023-03-03 20:39:01
【问题描述】:

我想证明 textview 中的文本。有什么方法可以证明 textview 中的内容。我不想使用 webview...有它的库吗?请帮助我...提前谢谢..

对齐.xml

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
     android:background="@drawable/back1"
    android:orientation="vertical" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:src="@drawable/banner" />

    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_marginLeft="120dp"
        android:layout_marginTop="20dp"
        android:text="About Us" />

    <ScrollView
        android:id="@+id/scrollView1"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_alignParentTop="true" >

            <TextView
                android:id="@+id/textView"
                android:layout_width="fill_parent"
                android:layout_height="fill_parent"

                android:layout_weight="0.94"
                android:text="Paragraph\n\nParagraph"

    </ScrollView>

活动

public class About_us extends Activity {
TextView txtName;
TextView txtName1;
    @SuppressLint("NewApi")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_about_us);
        getActionBar().setDisplayHomeAsUpEnabled(true);
        txtName = (TextView) findViewById(R.id.textView);
        txtName.setTextColor(Color.WHITE);
        txtName1 = (TextView) findViewById(R.id.textView1);
        txtName1.setTextColor(Color.WHITE);
        txtName1.setTextSize(16);
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.about_us, menu);
        return true;
    }

【问题讨论】:

  • 你是什么意思证明 textview 内容?
  • 当你使用搜索引擎搜索android text justify时,你学到了什么?
  • 他们已经通过使用 webview 来做到这一点..我希望我的段落是合理的......

标签: android justify text-justify


【解决方案1】:

默认情况下,Android 不支持 TextView 中的完全对齐。您必须为此使用 WebView,但因为您不想使用 Webview。因此,解决方案是 ANDROID Text-Justify 2.0 库。

您可以在以下 github 链接上找到该库

https://github.com/bluejamesbond/TextJustify-Android

在同一链接上提供了完整的设置信息。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-06
    • 1970-01-01
    • 2012-02-16
    • 1970-01-01
    • 2016-05-07
    • 2015-01-11
    相关资源
    最近更新 更多