Im linking a previous stack question my question is similar to that one Im using NavigaitonDrawer type template project in ADT I have used these two methods but they don't work the app crashes
1st Method
int width = getResources().getDisplayMetrics().widthPixels/2;
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) p.getLayoutParams();
params.width = width;
p.setLayoutParams(params);
2nd Method
ViewGroup.LayoutParams params = (ViewGroup.LayoutParams) p.getLayoutParams();
params.width = getResources().getDisplayMetrics().widthPixels/2;
p.setLayoutParams(params);
This is similar question to what i need but it did not solved my problem
This is my NavigationDrawerFragment.java
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View p = (View) inflater.inflate(R.layout.fragment_navigation_drawer, container, false);
mDrawerListView = (ListView) p.findViewById(R.id.nav_drawer_listview);
......
...
return p;
}
This is my fragment__navigation_drawer.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://ift.tt/nIICcg"
xmlns:tools="http://ift.tt/LrGmb4"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<RelativeLayout
android:id="@+id/search_layout">
<ImageView/>
<EditText/>
</RelativeLayout>
<ListView
android:id="@+id/nav_drawer_listview"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</ListView>
</RelativeLayout>
No comments:
Post a Comment