我在我的應用程序中有一個導航抽屜活動,我在那裏有一些片段。在一個片段中,我有一個滾動視圖,裏面有我單選按鈕組。單選按鈕是從數據庫獲取的數據中動態添加的。問題是滾動視圖是在應用 此的頂部隱藏2個單選按鈕是xml文件滾動視圖隱藏頂部單選按鈕
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.nimesha.delivery.Curjob_fragment">
<Button
android:id="@+id/naviBtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Navigate"
android:layout_marginRight="18dp"
android:layout_marginEnd="18dp"
android:layout_marginBottom="18dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
android:id="@+id/signoutbtn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="52dp"
android:layout_marginStart="52dp"
android:text="Button"
android:layout_below="@+id/scrollView2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ScrollView
android:id="@+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/naviBtn"
android:layout_marginTop="@dimen/nav_header_vertical_spacing"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:clipToPadding="true"
android:fillViewport="true"
android:layout_weight="1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RadioGroup
android:id="@+id/radioGrp"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
</ScrollView>
</RelativeLayout>
這是我如何填充單選按鈕組
for (DataSnapshot jobSnap: dataSnapshot.getChildren()) {
String key = jobSnap.getKey();
Double lat = jobSnap.child("lat").getValue(Double.TYPE);
Double longi =jobSnap.child("long").getValue(Double.TYPE);
Log.d(TAG, key + " " + lat + " " + longi);
RadioButton radioButton = new RadioButton(getActivity());
radioButton.setLayoutParams
(new RadioGroup.LayoutParams
(RadioGroup.LayoutParams.WRAP_CONTENT, RadioGroup.LayoutParams.WRAP_CONTENT));
radioButton.setText("Radio Button #" + lat);
radioButton.setId(count);
//add it to the group.
radiogroup.addView(radioButton, count);
count += 1 ;
}
https://i.stack.imgur.com/26Qfj.jpg
應該再頂上一些單選按鈕
它們是隱藏的還是未添加到組中? –
他們被添加,但一些按鈕放在活動標題欄後面 –