布局怎么添加个按钮?
本帖最后由 oktongguo 于 2022-11-9 23:08 编辑这是某个软件的布局,我想在最后一个ImageView后面,添加一个按钮,不知道怎么添加。在第421行直接添加<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Button"/>
不起作用,可能添加的位置不对,大神看看怎么添加,在哪个位置添加?
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="@drawable/live_partner_page_background"
android:paddingLeft="15.0dip"
android:paddingRight="15.0dip"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.yxcorp.gifshow.image.KwaiImageView
android:id="@id/avatar"
android:padding="1.0dip"
android:layout_width="@dimen/live_pusher_avatar_size"
android:layout_height="@dimen/live_pusher_avatar_size"
android:layout_marginTop="10.0dip"
android:scaleType="fitXY"
app:layout_constraintStart_toStartOf="0"
app:layout_constraintTop_toTopOf="0"
app:roundAsCircle="true"
app:roundingBorderColor="#80FFFFFF"
app:roundingBorderWidth="1.0dip"/>
<TextView
android:textSize="@dimen/text_size_12"
android:textStyle="bold"
android:textColor="@color/live_partner_text_white_color"
android:ellipsize="end"
android:id="@id/user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="8.0dip"
android:text="@string/save_portfolio_prompt"
android:singleLine="true"
app:layout_constraintLeft_toRightOf="@id/avatar"
app:layout_constraintTop_toTopOf="@id/avatar"/>
<com.kwai.livepartner.widget.SizeAdjustableTextView
android:textSize="@dimen/text_size_12"
android:textColor="@color/p_color_white_alpha50"
android:gravity="bottom"
android:id="@id/live_like_count"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="点爱心了"
android:singleLine="true"
android:layout_alignParentEnd="true"
app:layout_constraintBottom_toBottomOf="@id/avatar"
app:layout_constraintStart_toStartOf="@id/user_name"
app:textSizeAdjustable="true"/>
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@id/avatar"
app:layout_constraintLeft_toRightOf="@id/user_name"
app:layout_constraintRight_toRightOf="0"
app:layout_constraintTop_toTopOf="@id/avatar">
<com.kwai.livepartner.widget.SizeAdjustableTextView
android:textSize="@dimen/text_size_10"
android:textColor="@color/p_color_white"
android:ellipsize="end"
android:gravity="center"
android:id="@id/viewer_count"
android:background="@drawable/live_audience_number_bg"
android:paddingLeft="8.0dip"
android:paddingRight="8.0dip"
android:layout_width="wrap_content"
android:layout_height="@dimen/live_user_size"
android:layout_marginLeft="-9.0dip"
android:maxWidth="85.0dip"
android:minWidth="40.0dip"
android:maxLines="1"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"/>
<com.kwai.livepartner.widget.CustomFadeEdgeRecyclerView
android:id="@id/viewer_list"
android:fadingEdgeLength="100.0dip"
android:layout_width="wrap_content"
android:layout_height="32.0dip"
android:minWidth="100.0dip"
android:layout_toLeftOf="@id/viewer_count"
android:overScrollMode="never"
app:cerv_enableLeftFadingEdge="true"
app:cerv_enableRightFadingEdge="false"/>
</RelativeLayout>
<com.kwai.livepartner.widget.RoundedImageView
android:id="@id/game_bitmap"
android:layout_width="fill_parent"
android:layout_height="200.0dip"
android:layout_marginTop="25.0dip"
android:scaleType="centerCrop"
app:android_scaleType="6"
app:layout_constraintEnd_toEndOf="0"
app:layout_constraintStart_toStartOf="0"
app:layout_constraintTop_toBottomOf="@id/avatar"
app:riv_corner_radius_bottom_left="4.0dip"
app:riv_corner_radius_bottom_right="4.0dip"
app:riv_corner_radius_top_left="4.0dip"
app:riv_corner_radius_top_right="4.0dip"/>
<com.yxcorp.widget.selector.view.SelectShapeTextView
android:layout_gravity="bottom"
android:layout_width="fill_parent"
android:layout_height="70.0dip"
app:kwai_gradient_angle="90"
app:kwai_gradient_endColor="@color/live_partner_shape_none_color"
app:kwai_gradient_startColor="@color/live_partner_shape_black_color_alpha80"
app:layout_constraintBottom_toBottomOf="@id/game_bitmap"
app:layout_constraintEnd_toEndOf="0"
app:layout_constraintStart_toStartOf="0"/>
<com.yxcorp.widget.selector.view.SelectShapeView
android:id="@id/dot"
android:layout_width="7.0dip"
android:layout_height="7.0dip"
android:layout_centerVertical="true"
android:layout_marginStart="10.0dip"
android:layout_marginEnd="2.5dip"
app:kwai_radius_style="@style/FullRound"
app:kwai_solid_color="#FFFF527B"
app:layout_constraintBottom_toBottomOf="@id/live_text"
app:layout_constraintStart_toStartOf="0"
app:layout_constraintTop_toTopOf="@id/live_text"/>
<TextView
android:textSize="@dimen/text_size_12"
android:textStyle="bold"
android:textColor="@color/live_partner_text_white_color"
android:id="@id/live_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10.0dip"
android:text="正在直播"
android:layout_marginStart="5.0dip"
app:layout_constraintBottom_toBottomOf="@id/game_bitmap"
app:layout_constraintLeft_toRightOf="@id/dot"/>
<com.kwai.livepartner.widget.TextTimer
android:textSize="@dimen/text_size_12"
android:textStyle="bold"
android:textColor="@color/live_partner_text_white_color"
android:gravity="center_vertical"
android:id="@id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="5.0dip"
app:layout_constraintBottom_toBottomOf="@id/live_text"
app:layout_constraintLeft_toRightOf="@id/live_text"
app:layout_constraintTop_toTopOf="@id/live_text"/>
<TextView
android:textSize="@dimen/text_size_12"
android:textStyle="bold"
android:textColor="@color/live_partner_text_white_color"
android:id="@id/network_status"
android:visibility="invisible"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="直播状态"
android:layout_marginStart="10.0dip"
app:layout_constraintBottom_toBottomOf="@id/live_text"
app:layout_constraintLeft_toRightOf="@id/time"
app:layout_constraintTop_toTopOf="@id/live_text"/>
<TextView
android:textSize="@dimen/text_size_12"
android:textStyle="bold"
android:textColor="@color/live_partner_text_white_color"
android:gravity="center_vertical"
android:layout_gravity="center_vertical|center_horizontal"
android:id="@id/game_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10.0dip"
android:text="@string/back_to_home"
android:drawableRight="@drawable/live_room_next_btn"
android:drawablePadding="6.0dip"
android:layout_marginEnd="10.0dip"
app:layout_constraintBottom_toBottomOf="@id/game_bitmap"
app:layout_constraintEnd_toEndOf="0"/>
<include
android:visibility="gone"
android:layout_width="0.0dip"
android:layout_height="0.0dip"
app:layout_constraintBottom_toBottomOf="@id/game_bitmap"
app:layout_constraintEnd_toEndOf="@id/game_bitmap"
app:layout_constraintStart_toStartOf="@id/game_bitmap"
app:layout_constraintTop_toTopOf="@id/game_bitmap"
layout="@layout/live_partner_privacy_bitmap_layout"/>
<com.yxcorp.plugin.fanstop.FansTopNoticeBubbleView
android:id="@id/fans_top_notice_bubble"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10.0dip"
android:layout_marginStart="6.0dip"
android:layout_marginEnd="6.0dip"
app:layout_constraintStart_toStartOf="@id/game_bitmap"
app:layout_constraintTop_toTopOf="@id/game_bitmap"/>
<com.yxcorp.plugin.wishlist.widget.WishesFloatView
android:id="@id/wish_float_view"
android:visibility="gone"
android:layout_width="0.0dip"
android:layout_height="wrap_content"
android:layout_marginTop="10.0dip"
android:layout_marginStart="6.0dip"
android:layout_marginEnd="6.0dip"
app:layout_constraintEnd_toEndOf="@id/game_bitmap"
app:layout_constraintStart_toStartOf="@id/game_bitmap"
app:layout_constraintTop_toBottomOf="@id/fans_top_notice_bubble"
app:layout_goneMarginTop="10.0dip"/>
<com.kwai.livepartner.widget.LivePartnerCommonNoticeView
android:id="@id/common_notice_view"
android:visibility="gone"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="8.0dip"
app:layout_constraintLeft_toLeftOf="@id/message_list"
app:layout_constraintRight_toRightOf="@id/message_list"
app:layout_constraintTop_toBottomOf="@id/game_bitmap"/>
<LinearLayout
android:gravity="center"
android:orientation="vertical"
android:id="@id/live_partner_activity_pendant_container"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4.0dip"
android:layout_marginEnd="4.0dip"
app:layout_constraintRight_toRightOf="@id/game_bitmap"
app:layout_constraintTop_toTopOf="@id/game_bitmap">
<androidx.viewpager.widget.ViewPager
android:id="@id/pendant_view_pager"
android:layout_width="100.0dip"
android:layout_height="34.0dip"
app:layout_constraintLeft_toLeftOf="0"
app:layout_constraintRight_toRightOf="0"
app:layout_constraintTop_toBottomOf="@id/anchor_novice_task_started_week_layout"/>
<com.kwai.livepartner.widget.GzonePagerIndicator
android:id="@id/pendant_pager_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4.0dip"/>
</LinearLayout>
<com.kwai.livepartner.widget.CustomFadeEdgeRecyclerView
android:id="@id/message_list"
android:layout_width="fill_parent"
android:layout_height="0.0dip"
android:layout_marginTop="6.0dip"
android:layout_marginBottom="25.0dip"
app:cerv_enableBottomFadingEdge="true"
app:cerv_enableTopFadingEdge="true"
app:layout_constraintBottom_toTopOf="@id/live_partner_center_btn"
app:layout_constraintStart_toStartOf="0"
app:layout_constraintTop_toBottomOf="@id/common_notice_view"
app:layout_goneMarginTop="30.0dip"/>
<com.yxcorp.plugin.chat.LiveChatWithGuestEntryView
android:id="@id/live_chat_guest_list_entry"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10.0dip"
app:layout_constraintBottom_toTopOf="@id/live_chat_link_view"
app:layout_constraintEnd_toEndOf="0"
app:layout_goneMarginBottom="18.0dip"/>
<com.yxcorp.plugin.chat.LiveChatStateView
android:id="@id/live_chat_link_view"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="18.0dip"
app:layout_constraintBottom_toTopOf="@id/live_close"
app:layout_constraintEnd_toEndOf="0"/>
<com.yxcorp.plugin.redpacket.LiveRedPacketPendantContainerView
android:id="@id/live_red_packet_container_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10.0dip"
app:layout_constraintBottom_toTopOf="@id/live_chat_guest_list_entry"
app:layout_constraintEnd_toEndOf="0"
app:layout_goneMarginBottom="18.0dip"/>
<ViewStub
android:id="@id/live_vote_pendant_view_stub"
android:layout="@layout/live_vote_pendant_container"
android:layout_width="56.0dip"
android:layout_height="56.0dip"
app:layout_constraintBottom_toTopOf="@id/live_red_packet_container_view"
app:layout_constraintEnd_toEndOf="0"/>
<LinearLayout
android:gravity="bottom"
android:orientation="horizontal"
android:id="@id/live_partner_bottom_container"
android:layout_width="0.0dip"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@id/live_close"
app:layout_constraintStart_toStartOf="0"
app:layout_constraintWidth_max="144.0dip">
<FrameLayout
android:id="@id/live_partner_red_packet_container"
android:layout_width="@dimen/bottom_bar_item_size"
android:layout_height="@dimen/bottom_bar_item_size"
android:layout_marginRight="@dimen/bottom_bar_item_margin">
<ImageView
android:id="@id/live_partner_red_packet_btn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/live_red_packet_button"/>
<com.yxcorp.widget.selector.view.SelectShapeView
android:layout_gravity="right"
android:id="@id/red_packet_dot"
android:layout_width="5.0dip"
android:layout_height="5.0dip"
android:layout_marginTop="2.0dip"
android:layout_marginRight="2.0dip"
app:kwai_radius_style="@style/FullRound"
app:kwai_solid_color="#FFFF527B"/>
</FrameLayout>
<ImageView
android:id="@id/live_partner_shop_btn"
android:visibility="gone"
android:layout_width="@dimen/bottom_bar_item_size"
android:layout_height="@dimen/bottom_bar_item_size"
android:layout_marginRight="@dimen/bottom_bar_item_margin"
android:src="@drawable/live_partner_shop_button"
android:scaleType="fitStart"/>
<ImageView
android:id="@id/live_partner_magnet_star_btn"
android:visibility="gone"
android:layout_width="@dimen/bottom_bar_item_size"
android:layout_height="@dimen/bottom_bar_item_size"
android:layout_marginRight="@dimen/bottom_bar_item_margin"
android:src="@drawable/live_partner_magnet_button"
android:scaleType="fitStart"/>
<FrameLayout
android:id="@id/live_partner_paid_talent_container"
android:visibility="gone"
android:layout_width="@dimen/bottom_bar_item_size"
android:layout_height="wrap_content"
android:layout_marginRight="@dimen/bottom_bar_item_margin">
<ImageView
android:layout_gravity="bottom"
android:id="@id/live_paid_talent_btn"
android:layout_width="@dimen/bottom_bar_item_size"
android:layout_height="@dimen/bottom_bar_item_size"
android:src="@drawable/live_paid_talent_icon"/>
<com.kwai.livepartner.widget.LiveNumberTextView
android:textSize="11.0dip"
android:textColor="@color/s_FE3666"
android:layout_gravity="bottom"
android:id="@id/live_paid_talent_btn_corner"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="26.0dip"
android:layout_marginBottom="25.0dip"
android:text="3"
android:includeFontPadding="false"
app:layout_constraintBottom_toBottomOf="@id/live_paid_talent_btn"/>
</FrameLayout>
<com.yxcorp.widget.selector.view.SelectShapeImageView
android:id="@id/live_partner_camera_live_view"
android:padding="4.0dip"
android:layout_width="@dimen/bottom_bar_item_size"
android:layout_height="@dimen/bottom_bar_item_size"
android:layout_marginRight="@dimen/bottom_bar_item_margin"
android:src="@drawable/live_partner_camera_live_icon_in_bottom_sheet"
app:kwai_shape="1"
app:kwai_solid_color="@color/translucent_10_white"/>
<FrameLayout
android:id="@id/live_partner_guess_container"
android:layout_width="@dimen/bottom_bar_item_size"
android:layout_height="@dimen/bottom_bar_item_size"
android:layout_marginRight="@dimen/bottom_bar_item_margin">
<ImageView
android:id="@id/live_partner_guess_btn"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/live_guess_button"/>
<com.yxcorp.widget.selector.view.SelectShapeView
android:layout_gravity="right"
android:id="@id/live_partner_guess_red_dot_view"
android:visibility="gone"
android:layout_width="5.0dip"
android:layout_height="5.0dip"
android:layout_marginTop="2.0dip"
android:layout_marginRight="2.0dip"
app:kwai_radius_style="@style/FullRound"
app:kwai_solid_color="@color/s_FF5353"/>
</FrameLayout>
</LinearLayout>
<com.yxcorp.widget.selector.view.SelectShapeTextView
android:textSize="@dimen/text_size_14"
android:textColor="@color/text_color11"
android:gravity="center"
android:id="@id/live_partner_center_btn"
android:layout_width="0.0dip"
android:layout_height="36.0dip"
android:layout_marginRight="15.0dip"
android:text="@string/back_to_launcher"
app:kwai_pressed_solid_color="#0DFFFFFF"
app:kwai_radius_style="@style/FullRound"
app:kwai_unPressed_solid_color="#1AFFFFFF"
app:layout_constraintBottom_toBottomOf="@id/live_close"
app:layout_constraintLeft_toRightOf="@id/live_partner_bottom_container"
app:layout_constraintRight_toLeftOf="@id/live_partner_more_btn"/>
<com.yxcorp.gifshow.image.KwaiImageView
android:id="@id/live_partner_more_btn"
android:layout_width="@dimen/bottom_bar_item_size"
android:layout_height="@dimen/bottom_bar_item_size"
android:layout_marginEnd="14.0dip"
app:layout_constraintBottom_toBottomOf="@id/live_close"
app:layout_constraintRight_toLeftOf="@id/live_close"
app:placeholderImage="@drawable/live_partner_live_more_button"/>
<com.yxcorp.widget.selector.view.SelectShapeView
android:id="@id/more_dot"
android:visibility="gone"
android:layout_width="5.0dip"
android:layout_height="5.0dip"
android:layout_marginTop="2.0dip"
android:layout_marginEnd="2.0dip"
app:kwai_radius_style="@style/FullRound"
app:kwai_solid_color="#FFFF527B"
app:layout_constraintEnd_toEndOf="@id/live_partner_more_btn"
app:layout_constraintTop_toTopOf="@id/live_partner_more_btn"/>
<ImageView
android:id="@id/live_close"
android:layout_width="@dimen/bottom_bar_item_size"
android:layout_height="@dimen/bottom_bar_item_size"
android:layout_marginBottom="@dimen/bottom_bar_bottom_margin"
android:src="@drawable/live_partner_live_close"
app:layout_constraintBottom_toBottomOf="0"
app:layout_constraintEnd_toEndOf="0"/>
<com.yxcorp.plugin.camera.LivePartnerCameraPreviewGestureView
android:id="@id/live_camera_view"
android:visibility="gone"
android:layout_width="136.0dip"
android:layout_height="98.0dip"
app:layout_constraintStart_toStartOf="0"
app:layout_constraintTop_toTopOf="0"/>
</androidx.constraintlayout.widget.ConstraintLayout> 你的顶级布局是 "ConstraintLayout" 要添加控件得使用 "layout_constraint*"来定位
要看你添加布局在哪个方向了,比如要添加在ImageView 底下 得用 "app:layout_constraintTop_toBottomOf="@+id/xxx"" 可在As里面直接拖动绑定
页:
[1]