这里的问题是我试图使用“alignParentBottom = true”将textview粘贴到底部,但它隐藏了textview。以下是布局xml文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"
android:weightSum="1">
<Switch
android:onClick="adjustFocus"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hhmm"
android:id="@+id/hhmm"
android:checked="false"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Switch
android:onClick="adjustFocus"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hr12"
android:id="@+id/hr12"
android:checked="false"
android:layout_below="@+id/hhmm" />
<Switch
android:onClick="adjustFocus"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hr24"
android:id="@+id/hr24"
android:checked="false"
android:layout_below="@+id/hr12" />
<Switch
android:onClick="adjustFocus"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/hh_double"
android:id="@+id/hhdbl"
android:checked="false"
android:layout_below="@+id/hr24" />
<Switch
android:onClick="adjustFocus"
android:layout_margin="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/mm_double"
android:id="@+id/mmdbl"
android:checked="false"
android:layout_below="@+id/hhdbl" />
<TextView
android:textColor="@color/black"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="@string/offset"
android:id="@+id/textView2"
android:layout_below="@+id/mmdbl"
android:layout_margin="10dp" />
//below is the textview I'm trying to stick to the bottom
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView3"
android:background="@color/black"
android:textColor="@color/white"
android:layout_alignParentBottom="true"
/>
</RelativeLayout>
以下是与上述布局xml文件关联的java代码。这是一个片段......
public class myfrag extends Fragment {
TextView tv;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.my_fragment, container, false);
tv = (TextView)v.findViewById(R.id.textView3);
return v;
}
}
请在我错的地方帮助我。
答案 0 :(得分:0)
更新此TextView:
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:text="Large Text"
android:id="@+id/textView3"
android:background="#111111"
android:textColor="@color/white"
android:layout_alignParentBottom="true"
android:layout_below="@+id/textView2"
android:gravity="center|bottom" />