I'm trying to make an Android Wear app that has two pages.
I created:
InsetActivity
GridViewPager
FragmentGridPagerAdapter
Two classes extended from CardFragment
Two custom layout files that use BoxInsetLayout
One of the layout files is as follows:
<android.support.wearable.view.BoxInsetLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/history_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/background">
<FrameLayout
android:id="#+id/frame_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_box="all">
<android.support.wearable.view.WearableListView
android:id="#+id/history_list"
android:layout_width="match_parent"
android:layout_height="match_parent">
</android.support.wearable.view.WearableListView>
</FrameLayout>
</android.support.wearable.view.BoxInsetLayout>
InsetActivity.isRound() returns true, but BoxInsetLayout.isRound() returns false.
Two error messages are shown in console:
E/RecyclerView﹕ No adapter attached; skipping layout
What's wrong?
Related
In the Material Design TextLayoutinput endIconMode attribute not found how to archive below design
Thanks Advance !
you could add a right drawable to TextInputEditText like :
<android.support.design.widget.TextInputLayout
android:id="#+id/til_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:boxBackgroundMode="outline"
android:layout_margin="10dp">
<android.support.design.widget.TextInputEditText
android:id="#+id/tiet_password"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableRight="#drawable/icon"//add the right drawable
android:inputType="textPassword"/>
</android.support.design.widget.TextInputLayout>
Work for me
<com.google.android.material.textfield.TextInputLayout
...
app:endIconDrawable="#drawable/ic_close_gray_24dp"
app:endIconMode="custom">
I have a gridview in my app and i'm able to increase its height dynamically. But my issue is that every time i increase the height, the scrollbar scrolls to the center of the page. What could cause this issue ? Here is my code below :
Axml :
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:gravity="center"
android:background="#e1effa">
<GridView
android:id="#+id/gvPhones"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:verticalSpacing="5dp"
android:drawSelectorOnTop="true"
android:stretchMode="columnWidth" />
</LinearLayout>
</android.support.v4.widget.NestedScrollView>
Cs :
_mySimpleItemLoader = new LoadRecords();
_mySimpleItemLoader.LoadMoreItems();
gvPhone = FindViewById<GridView>(Resource.Id.gvPhones);
_gridviewAdapter = new PhonesAdapter(this, _mySimpleItemLoader, this);
gvPhone.Adapter = _gridviewAdapter;
gvPhone.LayoutParameters.Height = 777 * gvPhone.Count;
But my issue is that every time i increase the height, the scrollbar scrolls to the center of the page.
When you open an Activity, some control needs to take focus. But in your .axml layout there's no designated control to take focus, the system chooses the first eligible control that wants focus.
When you set the android:focusableInTouchMode="true" property in your LinearLayout, your LinearLayout will be focused on start and your NestedScrollView won't scroll to the center of the page.
I'm trying to use WearableActionDrawer in my app. Previously I was using 'com.google.android.support:wearable:2.0.0-alpha1' and my layout looks like this:
<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.drawer.WearableDrawerLayout
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/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:rectLayout="#layout/rect_activity_main"
app:roundLayout="#layout/round_activity_main"
tools:context="com.example.grant.wearableclimbtracker.MainActivity"
tools:deviceIds="wear">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id = "#+id/content_frame">
<android.support.wearable.view.GridViewPager
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</android.support.v4.widget.NestedScrollView>
<android.support.wearable.view.drawer.WearableNavigationDrawer
android:id = "#+id/top_navigation_drawer"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:background="#color/dark_grey"/>
<android.support.wearable.view.drawer.WearableActionDrawer
android:id="#+id/bottom_action_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/grey" />
</android.support.wearable.view.drawer.WearableDrawerLayout>
After I switched to 'com.google.android.support:wearable:2.0.0' the behavior changed. The action drawer used to stay out of view until I swiped up to reveal the action menu, but now there is a peek view of the drawer that doesn't go away unless I open the menu and select something. Is this the intended behavior? It takes up a lot of real-estate:
Any advice would be much appreciated.
It was as I suspected, when NestedScrollingChild height matched the parentview, the action drawer peeks. The only way I could get it to hide was to increase the NestedScrollingChild view by 1dp:
// get the screen width
DisplayMetrics metrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
// set height of framelayout to be slightly larger than view
mSessionLayout = rootView.findViewById(R.id.sessionLayout);
mSessionLayout.setMinimumHeight(metrics.heightPixels+1);
I Want to Create a List View with a Custom layout which will contain A image and text
But all the tutorials i find all extend List Activity but i cant extend List Activity because i need to add buttons and other things to the layout.
I need to use the ListView using a custom item layout
any ideas on how to do it?
You are not bound to use ListActivity in order to have a ListView in your layout. All the samples using ListActivity are there because people are lazy ;)
So just use a regular Activity and then you simply have to add the ListView to the layout you are setting as content view. This could look something like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/listView"
android:layout_width="match_parent"
android:layout_height="0"
android:layout_weight="1" />
<Button
android:id="#+id/somethingButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Do something" />
<Button
android:id="#+id/elseButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Do something else" />
</LinearLayout>
Then in like any other Activity in your OnCreate method you do:
SetContentView(Resource.Layout.myLayout); // myLayout.axml
var listView = FindViewById<ListView>(Resource.Id.listView);
listView.Adapter = new MyAdapter(context, itemsSource);
var somethingButton = FindViewById<Button>(Resource.Id.somethingButton);
var elseButton = FindViewById<Button>(Resource.Id.elseButton);
... more code ...
ListView is just a layout just like any other, so there is nothing magic about it. MyAdapter in this sample is ofcourse something you implement, which takes your data and presents it in the desired image and text layout.
For more information about ListView and Adapter please refer to the excellent documentation which Xamarin provides.
I'm trying to use .addView to add another LinearLayout to the ViewGroup.
I am getting the following error on LogCat:
05-21 16:23:04.096: E/AndroidRuntime(2086): FATAL EXCEPTION: main
05-21 16:23:04.096: E/AndroidRuntime(2086): java.lang.NullPointerException
05-21 16:23:04.096: E/AndroidRuntime(2086): at android.view.ViewGroup.addView(ViewGroup.java:3148)
05-21 16:23:04.096: E/AndroidRuntime(2086): at android.view.ViewGroup.addView(ViewGroup.java:3131)
This is the code being called:
final LinearLayout eventContainerSub =
(LinearLayout) findViewById(R.layout.event_container);
final LinearLayout eventContainer =
(LinearLayout) findViewById(R.id.eventContainer);
eventContainer.addView(eventContainerSub);
Here is the ViewGroup (the first linear layout):
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:id="#+id/eventContainer"
android:weightSum="100"
android:duplicateParentState="true">
And this is the (second) LinearLayout I'm adding to the (first one) LinearLayout above:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/eventContainerSub">
Both containers have the exact same name..eventContainerSub.
There is no eventContainer, change the view group to be the container as you planned..
<LinearLayout
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:animateLayoutChanges="true"
android:id="#+id/event_container"
android:weightSum="100"
android:duplicateParentState="true">
and make sure the code is asking for the right Ids:
final LinearLayout eventContainerSub =
(LinearLayout) findViewById(R.layout.eventContainerSub);
final LinearLayout eventContainer =
(LinearLayout) findViewById(R.id.event_container);
I'd also suggest you first remove the SubContainer from the view if it got inflated, as that view already has a parent and you cannot attach the SubContainer to two parents.
Either leave the subcontainer from this file and create a new one, or remove from the parent and only then add to the ViewGroup you want.
Android layout replacing a view with another view on run time
Call removeView() on the child's parent first