复制/粘贴的弹出菜单没有完整显示

时间:2018-10-29 11:52:31

标签: java android xml android-layout kotlin

当我双击或长按EditText中的文本时,带有复制/粘贴选项的PopupMenu不会完整显示。

我使用一个活动,该活动承载有关详细消息的片段。我也尝试使用Popup的样式,但没有结果。 enter image description here

我在活动中使用的样式

<style name="AppThemeNoActionBar" parent="Theme.AppCompat.Light.NoActionBar">
    <item name="colorPrimaryDark">@color/black</item>
    <item name="colorAccent">@color/white</item>

    <item name="searchViewStyle">@style/AppSearchViewStyle</item>

    <!--Текст-->
    <item name="android:gravity">center</item>
    <item name="android:textColor">@color/gold</item>
    <item name="android:textSize">@dimen/general_text_size</item>
    <item name="android:fontFamily">@font/basis_grotesque_pro_regular</item>
    <item name="actionMenuTextColor">@color/white</item>

    <item name="popupMenuStyle">@style/MyPopup</item>
    <item name="android:popupMenuStyle">@style/MyPopup</item>
  </style>

  <style name="MyPopup" parent="Base.Widget.AppCompat.PopupMenu">
    <item name="android:popupBackground">@color/gold</item>
    <item name="android:textColor">@color/black</item>
    <item name="android:itemBackground">@color/white</item>
  </style>

  <style name="AppSearchViewStyle" parent="Widget.AppCompat.SearchView">
    <item name="queryBackground">@android:color/transparent</item>
    <item name="searchIcon">@drawable/search_icon</item>
    <item name="android:imeActionId">6</item>
  </style>

说明片段布局

<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/black"
    >

  <include
      layout="@layout/util_toolbar_and_header"
      android:id="@+id/util_description_toolbar_and_header"
      />

  <EditText
      android:id="@+id/util_description_message"
      android:layout_width="@dimen/fill_parent"
      android:layout_height="@dimen/fill_parent"
      android:layout_marginBottom="8dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="30dp"
      android:layout_marginTop="8dp"
      android:fontFamily="@font/basis_grotesque_pro_regular"
      android:gravity="start"
      android:textColor="@color/white"
      android:textColorHighlight="@color/gold"
      app:layout_constraintBottom_toTopOf="@+id/util_description_button"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/util_description_toolbar_and_header"
      tools:text="Совсем плохое освещение в туалете, люди не могут скрутить трубочку. Совсем плохое освещение в туалете, люди не могут скрутить трубочку."
      />

  <Button
      android:id="@+id/util_description_button"
      android:layout_width="300dp"
      android:layout_height="80dp"
      android:layout_marginBottom="8dp"
      android:layout_marginEnd="8dp"
      android:layout_marginStart="8dp"
      android:background="@drawable/ic_general_button"
      android:textAllCaps="false"
      android:textSize="25sp"
      app:layout_constraintBottom_toBottomOf="parent"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      tools:text="Отправить идею"
      />

</android.support.constraint.ConstraintLayout>

我包含在布局中的工具栏和标题

<android.support.constraint.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/util_toolbar_and_header_container"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    >
  <android.support.v7.widget.Toolbar
      android:id="@+id/util_toolbar"
      android:layout_width="match_parent"
      android:layout_height="?android:actionBarSize"
      android:layout_alignParentTop="true"
      android:background="@color/black"
      app:collapseIcon="@drawable/menu_back_arrow"
      app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
      app:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
      >

    <android.support.constraint.ConstraintLayout
        android:id="@+id/util_toolbar_back_button_container"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:layout_marginStart="21dp"
        >

      <ImageView
          android:id="@+id/util_toolbar_back_img"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginBottom="8dp"
          android:layout_marginTop="8dp"
          android:src="@drawable/menu_back_arrow"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          />

      <TextView
          android:id="@+id/util_toolbar_back_text"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginStart="8dp"
          android:fontFamily="@font/basis_grotesque_pro_bold"
          android:text="Назад"
          android:gravity="center|start"
          android:textColor="@color/white"
          app:layout_constraintBottom_toBottomOf="@+id/util_toolbar_back_img"
          app:layout_constraintStart_toEndOf="@+id/util_toolbar_back_img"
          app:layout_constraintTop_toTopOf="@+id/util_toolbar_back_img"
          />
    </android.support.constraint.ConstraintLayout>

    <android.support.constraint.ConstraintLayout
        android:id="@+id/util_toolbar_right_side_content"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        >

      <ImageView
          android:id="@+id/util_toolbar_right_side_icon"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginEnd="8dp"
          app:layout_constraintBottom_toBottomOf="@+id/util_toolbar_right_side_text"
          app:layout_constraintEnd_toStartOf="@+id/util_toolbar_right_side_text"
          app:layout_constraintTop_toTopOf="@+id/util_toolbar_right_side_text"
          tools:srcCompat="@drawable/menu_icon_add"
          />
      <TextView
          android:id="@+id/util_toolbar_right_side_text"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_marginEnd="8dp"
          android:fontFamily="@font/basis_grotesque_pro_bold"
          android:gravity="center|start"
          android:text="Борис"
          android:textColor="@color/white"
          app:layout_constraintBottom_toBottomOf="parent"
          app:layout_constraintEnd_toEndOf="parent"
          app:layout_constraintTop_toTopOf="parent"
          />
    </android.support.constraint.ConstraintLayout>
  </android.support.v7.widget.Toolbar>

  <TextView
      android:id="@+id/util_general_header"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:layout_marginStart="@dimen/general_header_margin_start"
      android:fontFamily="@font/basis_grotesque_pro_bold"
      android:gravity="start"
      android:textSize="@dimen/general_header_text_size"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/util_toolbar"
      tools:text="@android:string/dialog_alert_title"
      />

  <TextView
      android:id="@+id/util_general_header_detail_message"
      android:layout_width="@dimen/fill_parent"
      android:layout_height="wrap_content"
      android:layout_marginEnd="@dimen/general_margin"
      android:layout_marginStart="@dimen/general_header_margin_start"
      android:layout_marginTop="1dp"
      android:fontFamily="@font/basis_grotesque_pro_light"
      android:gravity="start"
      android:maxLines="2"
      android:textSize="16sp"
      android:paddingBottom="5dp"
      android:textColor="@color/grey"
      app:layout_constraintEnd_toEndOf="parent"
      app:layout_constraintStart_toStartOf="parent"
      app:layout_constraintTop_toBottomOf="@+id/util_general_header"
      tools:text="Выберете тему в которой вы хотите обсудить ошибки"
      />

</android.support.constraint.ConstraintLayout>

还有onCreateView(...)代码

override fun onCreateView(
    inflater: LayoutInflater,
    container: ViewGroup?,
    savedInstanceState: Bundle?
  ): View? {
    val view = inflater.inflate(R.layout.util_description_fragment, container, false)
    ButterKnife.bind(this, view)

    mWorkingDayAddHeader.text = "Текст события"
    mWorkingDayAddHeaderDetail.text = "Опишите максимально детально ваше событие"
    mWorkingDayAddButton.text = "Добавить событие"
    mWorkingDayAddRightSideText.text = "Борис"

    val wrapper = ContextThemeWrapper(activity!!, style.AppThemeNoActionBar)
    val popup = PopupMenu(wrapper, view)

    return view
  }

此外,可能您会对代码质量发表一些评论,这可能非常有用。预先感谢

1 个答案:

答案 0 :(得分:0)

{
  "product": true
}

根据上述代码,此弹出窗口的锚点视图将是片段。但这应该是EditText,对吧?