我想做出两个水平布局,底部是用于放置基本数字,顶部是用于显示数字的电源的位置:1²1²1² I' m使用两个editText。一个用于下标,另一个用于SuperScript。 ,还有一个按钮和一个TextView,通过点击按钮显示结果。 我的代码: 结果: :如何设置底座和电源编号的两个布局
你怎么看这样的想法?
我想做出两个水平布局,底部是用于放置基本数字,顶部是用于显示数字的电源的位置:1²1²1² I' m使用两个editText。一个用于下标,另一个用于SuperScript。 ,还有一个按钮和一个TextView,通过点击按钮显示结果。 我的代码: 结果: :如何设置底座和电源编号的两个布局
你怎么看这样的想法?
试试这个按照您的要求
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="20dp">
<TextView
android:id="@+id/base_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:textColor="@android:color/black"
android:textSize="20sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_toRightOf="@+id/base_value"
android:gravity="top"
android:text="n"
android:textColor="@android:color/black"
android:textSize="12sp" />
</RelativeLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="30dp"
android:gravity="center"
android:layout_margin="20dp">
<TextView
android:id="@+id/base_value_new"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:text="1"
android:textColor="@android:color/black"
android:textSize="20sp" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_gravity="bottom"
android:layout_toRightOf="@+id/base_value_new"
android:gravity="bottom"
android:text="n"
android:textColor="@android:color/black"
android:textSize="12sp" />
</RelativeLayout>
让我们知道,如果它不能正常工作。 如果您需要多个此布局,请尝试以编程方式在运行时创建视图。
请详细解释您的意思。你真的需要两个“水平布局”吗?或者你只是想能够显示上标指数? –
没有。我只想从用户那里获得并保存一些数学和物理表达式,其中可能包含下标和上标nmubers和符号 – CLONER
那么,在[本文]中有一些超级和下标的基本示例(http://stackoverflow.com/questions/3543454/subscript-and-superscript-a-string-in-android),但是如果你想在用户输入时将它应用到用户的输入中,这将需要更多的工作。 –