我想将TextView"Deficient"的基线与EditText"10000"的基线对齐.他们都在里面<android.support.percent.PercentRelativeLayout>
我尝试了以下,但无法让它工作.
<android.support.percent.PercentRelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.design.widget.TextInputLayout
android:id="@+id/textInputLayout_soil_nitrogen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
app:layout_widthPercent="63%">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Enter N of soil"
tools:text="10000" />
</android.support.design.widget.TextInputLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toEndOf="@id/textInputLayout_soil_nitrogen"
android:layout_toRightOf="@id/textInputLayout_soil_nitrogen"
app:layout_widthPercent="37%"
tools:text="Deficient" />
</android.support.percent.PercentRelativeLayout>
Run Code Online (Sandbox Code Playgroud)
给TextView类型提供20dp的顶部填充可以解决问题,但是对齐它们的基线会很不错.在这种情况下,这甚至可能吗?
我删除了textAppearance和id属性,顺便说一句.
android android-layout android-textinputlayout android-percent-library
我在一个values/fertilizers.xml文件中有一些化学名称字符串:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="grade_dap">Diammonium phosphate - DAP (18:46:00)</string>
<string name="grade_ssp">Single super phosphate - SSP (00:16:00)</string>
...
</resources>
Run Code Online (Sandbox Code Playgroud)
既然因为这个文件中的所有这些字符串都不应该被翻译,我可以将一个translatable="false"属性放到根<resources>元素中,还是必须将它放在所有单独的字符串元素中,如下所示:
<string name="grade_dap" translatable="false">Single super phosphate - SSP (00:16:00)</string>
android ×2