2015-06-28 19 views
9

Tôi đang cố gắng để có được chức năng sau trong ngăn điều hướng nhưng tôi không thể phá vỡ nó.Khi nhấp vào mục ngăn kéo điều hướng, chế độ xem danh sách mới trong ngăn điều hướng

kịch bản: -

Tôi gặp một Navigation Drawer. Khi nhấp vào bất kỳ mục nào trong ngăn điều hướng, tôi cần một chế độ xem danh sách để mở với nhiều mục trong đó, có thể được chọn tiếp tục cho một số loại chức năng. Tôi cũng đính kèm Hình ảnh sẽ Xác định nhu cầu của tôi theo cách thích hợp. Xin vui lòng có một loại tài liệu tham khảo của hình ảnh để có được những gì tôi về cơ bản và thực sự cần. navigation drawer with multiple list

Bất kỳ trợ giúp nào sẽ được đánh giá cao ..!

+1

Tại sao bạn không muốn sử dụng 'ExpandableListView' chẳng hạn? Nó sẽ là thực hành tốt nhất cho những gì bạn muốn. – rom4ek

+0

bạn đã không đề cập đến những gì đã không phá vỡ trong kịch bản của bạn? Bạn muốn danh sách Thành phố ở bên phải? hoặc bạn muốn danh sách menu được mở rộng? Vui lòng giải thích thêm –

+1

Giải pháp trường hợp xấu nhất sẽ là sử dụng hai chế độ xem danh sách với định hướng bố cục tuyến tính làm ngang và đặt chế độ hiển thị hiển thị và biến mất theo yêu cầu.Nhưng tôi muốn đề nghị bạn sử dụng giải pháp rom4ek. – Chitrang

Trả lời

4

như tôi đã nhìn thấy hình ảnh của bạn những gì tôi hiểu là, từ ngăn kéo của bạn bấm bạn muốn một danh sách khác xuất hiện đó là phía bên phải. tôi có đúng không Nếu tôi sửa thì không thể sử dụng ExpandableListViewExpandableListView sẽ tạo mục bên dưới mục được nhấp.

Vì vậy, một giải pháp là Bạn có thể lấy hai ListView.

Đầu tiên ListView bên trong ngăn kéomột lần thứ hai về nội dung chính của bạn và tạo bộ chuyển đổi tùy chỉnh cho cả ListView.

Bây giờ khi người dùng nhấp vào mục danh sách ngăn, xác định tùy chọn nào được nhấp như Thành phố, MyNews hoặc bất kỳ thứ gì.

Sau khi xác định nhấp chuột, bạn có thể điền vào bộ điều hợp cho ListView thứ hai theo tùy chọn nào được người dùng nhấp vào. và áp dụng bộ điều hợp đó cho ListView thứ hai và thông báo cho nó.

Vì vậy, khi người dùng nhấp vào một mục khác từ ngăn kéo, điều tương tự sẽ xảy ra. Nhưng dữ liệu cho ListView thứ hai sẽ thay đổi.

Tôi hy vọng bạn hiểu những gì tôi đang nói và nó giúp bạn.

[cập nhật]

Ok vậy xml của bạn shuold trông như thế này.

Lưu ý: Tôi chỉ đang viết bộ xương cho việc này.

<!-- The main content view --> 
<FrameLayout android:id="@+id/content_frame" /> 

<!-- The navigation drawer --> 
<LinearLayout 
    android:layout_gravity="start" 
    android:orientation="horizontal"> 
    <ListView 
     android:layout_weight="1" 
     android:id="@+id/list1"> 
    </ListView> 

    <ListView 
     android:layout_weight="1" 
     android:id="@+id/list2"> 
    </ListView> 
</LinearLayout> 

Bây giờ Về phía java của bạn. xem xét cả hai listview được tham chiếu như list1List2, và bạn đã tạo ra hai bộ chuyển đổi adapter1adapter2.

Make mục nhấp chuột cho list1 và áp dụng logic như dưới đây ...

list1.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
    @Override 
    public void onItemClick(AdapterView<?> adapterView, View view, int pos, long l) { 

     // now here you can get which option is clicked from list1. 
     // using position and 
     int your_type = pos; 

     adapter2.filderDataAccordingToType(your_type); 
     // create the above method in your second adapter and pass your type like MyNews, City or any other. 
     // and apply the logic of filtering by passing type to your method 
     // your_type could be any data type i have take the integer. 
     // and after filtering data you can notify your adapter. 
     // so when the data of adpater gets changed your secondlistview get refreshed. 
    } 
}); 

đó là nó. Tôi hy vọng nó sẽ giúp bạn.

+0

cũng có thể hữu ích. đặt Linear layour với chế độ xem danh sách nằm ngang trong ngăn kéo và giữ nguyên logic của bạn. nếu bạn có thể cắt nó, hãy làm như vậy. để tôi có thể chấp nhận câu trả lời của bạn. –

+0

Tôi chỉ là một chút bối rối mà bạn muốn cả hai listview cùng nhau trên ngăn kéo hoặc một listview trên ngăn kéo và một số khác bên ngoài ngăn kéo ..? Để tôi có thể cập nhật câu trả lời đúng cách ... – Moinkhan

+0

Cả hai trên ngăn kéo. –

3

Bạn có thể sử dụng hướng dẫn dành cho nhà phát triển Android trên creating a navigation drawer, nhưng thay vì sử dụng ListView, bạn hãy đi theo số ExpandableListView.

Ví dụ: trong hướng dẫn đó, bạn có thể thấy điều đó trong khối mã đầu tiên mà họ đang sử dụng ListView. Thay vì đó, thay đổi nó để một cái gì đó như thế này:

<android.support.v4.widget.DrawerLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/drawer_layout" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <FrameLayout 
     android:id="@+id/content_frame" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" /> 

    <ExpandableListView android:id="@+id/left_drawer" 
     android:layout_width="240dp" 
     android:layout_height="match_parent"/> 
</android.support.v4.widget.DrawerLayout> 

Làm thế nào để thực hiện một bộ chuyển đổi ExpandableListView được giải thích trong this hướng dẫn có sẵn tại Android Hive. Tôi không dán mã của họ ở đây bởi vì đó là một hướng dẫn dài. Bình luận dưới đây nếu bạn có bất kỳ câu hỏi nào.

0

đây là mã của tôi.

  • tôi đang sử dụng chế độ xem tái chế cho mục con.
  • nó đang mở rộng các từ.
  • tôi đang sử dụng 2 thư viện.

    biên dịch 'com.h6ah4i.android.widget.advrecyclerview: advrecyclerview: 0.7.1' biên dịch 'com.wnafee: vector compat: 1.0.5'

đây là Navigation Drawer Fragment

public class NavigationDrawerFragment extends Fragment implements NavigationDrawerCallbacks { 


private static final String SAVED_STATE_EXPANDABLE_ITEM_MANAGER = "RecyclerViewExpandableItemManager"; 

/** 
* Remember the position of the selected item. 
*/ 
private static final String STATE_SELECTED_POSITION = "selected_navigation_drawer_position"; 

/** 
* Per the design guidelines, you should show the drawer on launch until the user manually 
* expands it. This shared preference tracks this. 
*/ 
private static final String PREF_USER_LEARNED_DRAWER = "navigation_drawer_learned"; 

/** 
* A pointer to the current callbacks instance (the Activity). 
*/ 
private NavigationDrawerCallbacks mCallbacks; 

/** 
* Helper component that ties the action bar to the navigation drawer. 
*/ 
private ActionBarDrawerToggle mActionBarDrawerToggle; 

private DrawerLayout mDrawerLayout; 
private RecyclerView mDrawerList; 
private View mFragmentContainerView; 

private int mCurrentSelectedPosition = -1; 
private boolean mFromSavedInstanceState; 
private boolean mUserLearnedDrawer; 

private Subscription subscription; 

@Inject CategoryService categoryService; 

private MyExpandableItemAdapter expandableItemAdapter; 
private RecyclerView.Adapter wrappedAdapter; 
private RecyclerViewExpandableItemManager expandableItemManager; 
private LinearLayoutManager linearLayoutManager; 


@Override 
public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    DelhiShopApplication.component().inject(this); 

    // Read in the flag indicating whether or not the user has demonstrated awareness of the 
    // drawer. See PREF_USER_LEARNED_DRAWER for details. 
    SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(getActivity()); 
    mUserLearnedDrawer = sp.getBoolean(PREF_USER_LEARNED_DRAWER, false); 

    if (savedInstanceState != null) { 
     mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION); 
     mFromSavedInstanceState = true; 
    } 
} 

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
         Bundle savedInstanceState) { 
    View view = inflater.inflate(R.layout.fragment_navigation_drawer, container, false); 
    mDrawerList = (RecyclerView) view.findViewById(R.id.drawerList); 
    LinearLayoutManager layoutManager = new LinearLayoutManager(getActivity()); 
    layoutManager.setOrientation(LinearLayoutManager.VERTICAL); 
    mDrawerList.setLayoutManager(layoutManager); 
    mDrawerList.setHasFixedSize(true); 

    if (mCurrentSelectedPosition != -1) { 
     selectItem(mCurrentSelectedPosition); 
    } 
    return view; 
} 

@Override 
public void onViewCreated(View view, Bundle savedInstanceState) { 
    super.onViewCreated(view, savedInstanceState); 

    final Parcelable eimSavedState = (savedInstanceState != null) ? savedInstanceState.getParcelable(SAVED_STATE_EXPANDABLE_ITEM_MANAGER) : null; 
    expandableItemManager = new RecyclerViewExpandableItemManager(eimSavedState); 


} 

private void setRecyclerView(Category category) { 
    linearLayoutManager = new LinearLayoutManager(getActivity()); 

    final MyExpandableItemAdapter myItemAdapter = new MyExpandableItemAdapter(category); 
    wrappedAdapter = expandableItemManager.createWrappedAdapter(myItemAdapter); 


    final GeneralItemAnimator animator = new RefactoredDefaultItemAnimator(); 

    // Change animations are enabled by default since support-v7-recyclerview v22. 
    // Need to disable them when using animation indicator. 
    animator.setSupportsChangeAnimations(false); 

    mDrawerList.setLayoutManager(linearLayoutManager); 
    mDrawerList.setAdapter(wrappedAdapter); // requires *wrapped* adapter 
    mDrawerList.setItemAnimator(animator); 
    mDrawerList.setHasFixedSize(false); 

    // additional decorations 
    //noinspection StatementWithEmptyBody 

// if (supportsViewElevation()) { // // Lollipop hoặc mới hơn có tính năng đổ bóng gốc. ItemShadowDecorator là không cần thiết. //} else { // mDrawerList.addItemDecoration (new ItemShadowDecorator ((NinePatchDrawable) getResources(). GetDrawable (R.drawable // .material_shadow_z1))); //}

expandableItemManager.attachRecyclerView(mDrawerList); 
} 

private boolean supportsViewElevation() { 
    return (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP); 
} 

public boolean isDrawerOpen() { 
    return mDrawerLayout != null && mDrawerLayout.isDrawerOpen(mFragmentContainerView); 
} 

public ActionBarDrawerToggle getActionBarDrawerToggle() { 
    return mActionBarDrawerToggle; 
} 

public DrawerLayout getDrawerLayout() { 
    return mDrawerLayout; 
} 

@Override 
public void onNavigationDrawerItemSelected(int position) { 
    selectItem(position); 
} 

/** 
* Users of this fragment must call this method to set up the navigation drawer interactions. 
* 
* @param fragmentId The android:id of this fragment in its activity's layout. 
* @param drawerLayout The DrawerLayout containing this fragment's UI. 
* @param toolbar  The Toolbar of the activity. 
*/ 
public void setup(int fragmentId, DrawerLayout drawerLayout, Toolbar toolbar) { 
    mFragmentContainerView = (View) getActivity().findViewById(fragmentId).getParent(); 
    mDrawerLayout = drawerLayout; 

    mDrawerLayout.setStatusBarBackgroundColor(getResources().getColor(R.color.myPrimaryDarkColor)); 

    mActionBarDrawerToggle = new ActionBarDrawerToggle(getActivity(), mDrawerLayout, toolbar, R.string 
      .drawer_open, R.string.drawer_close) { 
     @Override 
     public void onDrawerClosed(View drawerView) { 
      super.onDrawerClosed(drawerView); 
      if (!isAdded()) { 
       return; 
      } 

      getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() 
     } 

     @Override 
     public void onDrawerOpened(View drawerView) { 
      super.onDrawerOpened(drawerView); 
      if (!isAdded()) { 
       return; 
      } 
      if (!mUserLearnedDrawer) { 
       mUserLearnedDrawer = true; 
       SharedPreferences sp = PreferenceManager 
         .getDefaultSharedPreferences(getActivity()); 
       sp.edit().putBoolean(PREF_USER_LEARNED_DRAWER, true).apply(); 
      } 
      getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu() 
     } 
    }; 

    // If the user hasn't 'learned' about the drawer, open it to introduce them to the drawer, 
    // per the navigation drawer design guidelines. 
    if (!mUserLearnedDrawer && !mFromSavedInstanceState) { 
     mDrawerLayout.openDrawer(mFragmentContainerView); 
    } 

    // Defer code dependent on restoration of previous instance state. 
    mDrawerLayout.post(new Runnable() { 
     @Override 
     public void run() { 
      mActionBarDrawerToggle.syncState(); 
     } 
    }); 

    mDrawerLayout.setDrawerListener(mActionBarDrawerToggle); 
} 

private void selectItem(int position) { 
    mCurrentSelectedPosition = position; 
    if (mDrawerLayout != null) { 
     mDrawerLayout.closeDrawer(mFragmentContainerView); 
    } 
    if (mCallbacks != null) { 
     mCallbacks.onNavigationDrawerItemSelected(position); 
    } 
    ((NavigationDrawerAdapter) mDrawerList.getAdapter()).selectPosition(position); 
} 

public void openDrawer() { 
    mDrawerLayout.openDrawer(mFragmentContainerView); 
} 

public void closeDrawer() { 
    mDrawerLayout.closeDrawer(mFragmentContainerView); 
} 

@Override 
public void onAttach(Activity activity) { 
    super.onAttach(activity); 
    try { 
     mCallbacks = (NavigationDrawerCallbacks) activity; 
    } catch (ClassCastException e) { 
     throw new ClassCastException("Activity must implement NavigationDrawerCallbacks."); 
    } 
} 

@Override 
public void onDetach() { 
    super.onDetach(); 
    mCallbacks = null; 
} 

@Override 
public void onSaveInstanceState(Bundle outState) { 
    super.onSaveInstanceState(outState); 
    outState.putInt(STATE_SELECTED_POSITION, mCurrentSelectedPosition); 
    if (expandableItemManager != null) { 
     outState.putParcelable(
       SAVED_STATE_EXPANDABLE_ITEM_MANAGER, 
       expandableItemManager.getSavedState()); 
    } 
} 

@Override 
public void onConfigurationChanged(Configuration newConfig) { 
    super.onConfigurationChanged(newConfig); 
    // Forward the new configuration the drawer toggle component. 
    mActionBarDrawerToggle.onConfigurationChanged(newConfig); 
} 

public void setUserData(String user, String email, Bitmap avatar) { 
    ((TextView) mFragmentContainerView.findViewById(R.id.txtUserEmail)).setText(email); 
    ((TextView) mFragmentContainerView.findViewById(R.id.txtUsername)).setText(user); 
} 

public View getGoogleDrawer() { 
    return mFragmentContainerView.findViewById(R.id.googleDrawer); 
} 

@Override 
public void onResume() { 
    super.onResume(); 
    subscription = categoryService.getCategories() 
      .subscribeOn(Schedulers.io()) 
      .observeOn(AndroidSchedulers.mainThread()) 
      .subscribe(new Action1<Category>() { 
       @Override 
       public void call(Category category) { 
        // sadfksdjf 
        expandableItemAdapter = new MyExpandableItemAdapter(category); 
        mDrawerList.setAdapter(expandableItemAdapter); 
        setRecyclerView(category); 
       } 
      }, new Action1<Throwable>() { 
       @Override 
       public void call(Throwable throwable) { 
        // slkdfj 
       } 

      }); 
} 


@Override 
public void onPause() { 
    subscription.unsubscribe(); 
    super.onPause(); 
} 

@Override 
public void onDestroyView() { 
    super.onDestroyView(); 
    if (expandableItemManager != null) { 
     expandableItemManager.release(); 
     expandableItemManager = null; 
    } 
} 

ở đây là tôi có thể mở rộng mục Adaptor

public class MyExpandableItemAdapter 
    extends AbstractExpandableItemAdapter<MyExpandableItemAdapter.MyGroupViewHolder, MyExpandableItemAdapter.MyChildViewHolder> { 
private static final String TAG = "MyExpandableItemAdapter"; 

private Category category; 

public static abstract class MyBaseViewHolder extends AbstractExpandableItemViewHolder { 
    public ViewGroup mContainer; 
    public View mDragHandle; 
    public TextView mTextView; 

    public MyBaseViewHolder(View v) { 
     super(v); 
     mContainer = (ViewGroup) v.findViewById(R.id.container); 
     mDragHandle = v.findViewById(R.id.drag_handle); 
     mTextView = (TextView) v.findViewById(android.R.id.text1); 

     // hide the drag handle 
     mDragHandle.setVisibility(View.GONE); 
    } 
} 

public static class MyGroupViewHolder extends MyBaseViewHolder { 
    public MorphButtonCompat mMorphButton; 

    public MyGroupViewHolder(View v) { 
     super(v); 
     mMorphButton = new MorphButtonCompat(v.findViewById(R.id.indicator)); 
    } 
} 

public static class MyChildViewHolder extends MyBaseViewHolder { 
    public MyChildViewHolder(View v) { 
     super(v); 
    } 
} 

public MyExpandableItemAdapter(Category dataProvider) { 
    category = dataProvider; 

    // ExpandableItemAdapter requires stable ID, and also 
    // have to implement the getGroupItemId()/getChildItemId() methods appropriately. 
    setHasStableIds(true); 
} 

@Override 
public int getGroupCount() { 
    return category.getSubCategorySize(); 
} 

@Override 
public int getChildCount(int groupPosition) { 
    return getGroupCategoryAtPosition(groupPosition).getSubCategorySize(); 
} 

@Override 
public long getGroupId(int groupPosition) { 
    return groupPosition; 
} 

@Override 
public long getChildId(int groupPosition, int childPosition) { 
    return groupPosition * 100 + childPosition; 
} 

@Override 
public int getGroupItemViewType(int groupPosition) { 
    return 0; 
} 

@Override 
public int getChildItemViewType(int groupPosition, int childPosition) { 
    return 0; 
} 

@Override 
public MyGroupViewHolder onCreateGroupViewHolder(ViewGroup parent, int viewType) { 
    final LayoutInflater inflater = LayoutInflater.from(parent.getContext()); 
    final View v = inflater.inflate(R.layout.list_group_item, parent, false); 
    return new MyGroupViewHolder(v); 
} 

@Override 
public MyChildViewHolder onCreateChildViewHolder(ViewGroup parent, int viewType) { 
    final LayoutInflater inflater = LayoutInflater.from(parent.getContext()); 
    final View v = inflater.inflate(R.layout.list_item, parent, false); 
    return new MyChildViewHolder(v); 
} 

@Override 
public void onBindGroupViewHolder(MyGroupViewHolder holder, int groupPosition, int viewType) { 
    // child item 

    final Category groupItem = getGroupCategoryAtPosition(groupPosition); 

    // set text 
    holder.mTextView.setText(groupItem.getCategoryName()); 

    // mark as clickable 
    holder.itemView.setClickable(true); 

    // set background resource (target view ID: container) 
    final int expandState = holder.getExpandStateFlags(); 

    if ((expandState & RecyclerViewExpandableItemManager.STATE_FLAG_IS_UPDATED) != 0) { 
     int bgResId; 
     MorphButton.MorphState indicatorState; 

     if ((expandState & RecyclerViewExpandableItemManager.STATE_FLAG_IS_EXPANDED) != 0) { 
      bgResId = R.drawable.bg_group_item_expanded_state; 
      indicatorState = MorphButton.MorphState.END; 
     } else { 
      bgResId = R.drawable.bg_group_item_normal_state; 
      indicatorState = MorphButton.MorphState.START; 
     } 

     holder.mContainer.setBackgroundResource(bgResId); 

     if (holder.mMorphButton.getState() != indicatorState) { 
      holder.mMorphButton.setState(indicatorState, true); 
     } 
    } 
} 

@Override 
public void onBindChildViewHolder(MyChildViewHolder holder, int groupPosition, int childPosition, int viewType) { 
    // group item 
    final Category childCategory = getChildCategory(groupPosition, childPosition); 
    // set text 
    holder.mTextView.setText(childCategory.getCategoryName()); 

    // set background resource (target view ID: container) 
    int bgResId; 
    bgResId = R.drawable.bg_item_normal_state; 
    holder.mContainer.setBackgroundResource(bgResId); 
} 


@Override 
public boolean onCheckCanExpandOrCollapseGroup(MyGroupViewHolder holder, int groupPosition, int x, int y, boolean expand) { 

    Category groupCategory = getGroupCategoryAtPosition(groupPosition); 

    if (groupCategory.getSubCategorySize() == 0) { 
     return false; 
    } 

    // check is enabled 
    if (!(holder.itemView.isEnabled() && holder.itemView.isClickable())) { 
     return false; 
    } 

    final View containerView = holder.mContainer; 
    final View dragHandleView = holder.mDragHandle; 

    final int offsetX = containerView.getLeft() + (int) (ViewCompat.getTranslationX(containerView) + 0.5f); 
    final int offsetY = containerView.getTop() + (int) (ViewCompat.getTranslationY(containerView) + 0.5f); 

    return !hitTest(dragHandleView, x - offsetX, y - offsetY); 
} 

private Category getGroupCategoryAtPosition(int groupPosition) { 
    return category.getSubCategory().get(groupPosition); 
} 

private Category getChildCategory(int groupPosition, int childPosition) { 
    return getGroupCategoryAtPosition(groupPosition).getSubCategory().get(childPosition); 
} 


public static boolean hitTest(View v, int x, int y) { 
    final int tx = (int) (ViewCompat.getTranslationX(v) + 0.5f); 
    final int ty = (int) (ViewCompat.getTranslationY(v) + 0.5f); 
    final int left = v.getLeft() + tx; 
    final int right = v.getRight() + tx; 
    final int top = v.getTop() + ty; 
    final int bottom = v.getBottom() + ty; 

    return (x >= left) && (x <= right) && (y >= top) && (y <= bottom); 
} 
} 

đây là list_group_item.xml tôi

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
style="@style/commonListItemStyle" 
android:layout_width="match_parent" 
android:layout_height="96dp" 
android:layout_marginTop="8dp" 
android:background="#ffffff"> 

<RelativeLayout 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:clickable="true" 
    tools:ignore="UselessParent"> 

    <View 
     android:id="@+id/drag_handle" 
     android:layout_width="32dp" 
     android:layout_height="match_parent" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:background="#20000000" 
     tools:ignore="RtlHardcoded" /> 

    <TextView 
     android:id="@android:id/text1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_toRightOf="@id/drag_handle" 
     android:gravity="center" /> 
</RelativeLayout> 

</FrameLayout> 

list_item.xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
style="@style/commonListItemStyle" 
android:layout_width="match_parent" 
android:layout_height="64dp" 
android:background="@drawable/bg_swipe_item_neutral"> 

<RelativeLayout 
    android:id="@+id/container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:clickable="true" 
    tools:ignore="UselessParent"> 

    <View 
     android:id="@+id/drag_handle" 
     android:layout_width="32dp" 
     android:layout_height="match_parent" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:background="#20000000" /> 

    <TextView 
     android:id="@android:id/text1" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_toRightOf="@id/drag_handle" 
     android:gravity="center" 
     tools:ignore="RtlHardcoded" /> 
</RelativeLayout> 

</FrameLayout> 
Các vấn đề liên quan