在不使用WebView的情况下在textview中对齐android文本

时间:2014-11-26 13:01:57

标签: android justify text-justify

我想证明textview中的文本是正确的。有什么方法可以证明textview中的内容。我不想使用webview ...是否有一个库?Plz帮助我。 ..提前谢谢..

Justify.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;
    }

1 个答案:

答案 0 :(得分:2)

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

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

<强> https://github.com/bluejamesbond/TextJustify-Android

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

相关问题