【发布时间】:2017-05-27 05:22:55
【问题描述】:
我最近看到一个 Android 应用程序,其中在单独的 Column 中的每一行之前添加了数字行。主列也与多行 TextView 一起滚动。如何将这些行号与 textview 一起添加?看截图:
我尝试通过添加 2 个具有相同字体大小的多行文本视图来实现它。
<LinearLayout
android:layout_width="match_parent"
android:orientation="horizontal"
android:layout_height="match_parent">
<TextView
android:id="@+id/ct"
android:layout_weight="0.075"
android:textColor="@android:color/darker_gray"
android:layout_width="0dp"
android:layout_marginRight="1dp"
android:background="#303133"
android:layout_height="match_parent"
android:inputType="textMultiLine"
android:textSize="15sp"/>
<ScrollView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:background="#303133">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/txt"
android:textColor="@android:color/white"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:textSize="15sp" />
</HorizontalScrollView>
</ScrollView>
</LinearLayout>
但是如何根据其他 Textview 在 NumberLine TextView 中添加相同数量的行?以及如何滚动 NumberLine TextView 以及其他 Textview ?毕竟还有其他方法可以实现吗?
【问题讨论】:
标签: java android android-layout android-studio textview