我有一个ConstraintLayout,其中包含一些按钮,该ConstraintLayout(在某些情况下)位于FrameLayout的后面,后者将他隐藏了。
我只需要从此ConstraintLayout中带一个特定按钮到ToFront,而不是所有按钮。
应该注意的是,在我首先带ConstraintLayout(隐藏)之前,我不能带按钮。我该怎么办?
这是ConstraintLayout:
<android.support.constraint.ConstraintLayout
android:id="@+id/inside_call_btns_cl"
android:layout_width="match_parent"
android:layout_height="0dp"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent">
<!--Buttons section-->
<ToggleButton
android:id="@+id/speaker_iv"
android:layout_width="68dp"
android:layout_height="68dp"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:background="@drawable/speaker_selector"
android:checked="true"
android:scaleType="fitCenter"
android:textOff=""
android:textOn=""
app:layout_constraintBottom_toBottomOf="@+id/bonus_rl"
app:layout_constraintEnd_toStartOf="@+id/bonus_rl"
app:layout_constraintStart_toStartOf="parent"></ToggleButton>
<ToggleButton
android:id="@+id/mute_iv"
android:layout_width="68dp"
android:layout_height="68dp"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:background="@drawable/mute_selector"
android:checked="false"
android:scaleType="fitCenter"
android:textOff=""
android:textOn=""
app:layout_constraintBottom_toBottomOf="@+id/bonus_rl"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toEndOf="@+id/bonus_rl" />
<RelativeLayout
android:id="@+id/bonus_rl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="35dp"
app:layout_constraintBottom_toTopOf="@+id/camera_switch_iv"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<app.components.CircleImageView
android:visibility="visible"
android:id="@+id/mic_flag_civ"
android:layout_width="67dp"
android:layout_height="67dp"
android:layout_centerInParent="true"
android:alpha="0.3"
android:src="@drawable/flag_united_states_of_america" />
<ImageView
android:visibility="visible"
android:id="@+id/bonus_rl_iv"
android:layout_width="68dp"
android:clickable="false"
android:layout_height="68dp"
android:layout_marginTop="3dp"
android:scaleType="fitCenter"
android:background="@drawable/bonus_rl_disabled" />
</RelativeLayout>
<ImageView
android:id="@+id/camera_switch_iv"
android:layout_width="54dp"
android:layout_height="54dp"
android:layout_marginBottom="35dp"
android:src="@drawable/ic_camera_switch"
android:visibility="visible"
app:layout_constraintBottom_toTopOf="@+id/decline_rl"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
<RelativeLayout
android:id="@+id/decline_rl"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="30dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<app.components.CircleImageView
</app.components.CircleImageView>
<ImageView
android:id="@+id/hang_up_iv"
----
----
---- />
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
然后FrameLayout覆盖此ConstraintLayout,我只需要将 bonus_rl 放在前面
答案 0 :(得分:0)
尝试:
view.getParent().bringChildToFront(view);
view.getParent().requestLayout();