I have a custom layout for the google tv and to get the layout to work, I override the dispatchkeyEvent in my activity to get my layout to work with the dpad. My layout also uses the gridview, and since I override the dispatchKeyEvent, I cant use the dpad with the gridview. Is there anyway to pass the key event to the gridview so I can use it?
Edit1: Apparently, the gridview cannot be focusd according to .isFocusable(). Is there anyway to force it to become focusable?
Edit2: I think the problem is the VideoView that is taking focus from all the controls?
Heres the layout I'm using. If I take out the VideoView, i am able to use the controls. The UI and Workspace layouts is my UI overlay over the video. Is there anway to get around this?
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center"
android:layout_weight="1" >
<VideoView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RelativeLayout
android:id="#+id/ui"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom" >
<LinearLayout
android:id="#+id/workspace"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="bottom" >
</LinearLayout>
</RelativeLayout>
</FrameLayout>
Related
I am trying to develop a face recognition application and I am using a SurfaceView inside a RelativeLayout. I was able to make the SurfaceView "TRANSPARENT" so I did not need to see the Camera preview, but now I am having a white background caused by the RelativeLayout and I can't make it Invisible so I don't see this background in my application.
I tried many things and i looked a lot of posts here in SO but I didn't find a solution for my situation.
Xml code (margins in relativelayout and surfaceview were for testing purposes):
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/topLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:keepScreenOn="true"
android:visibility="invisible">
<SurfaceView
android:id="#+id/surfaceview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="100dp"
/>
<android.support.v7.widget.RecyclerView
android:id="#+id/recycler_view"
android:layout_width="#dimen/image_preview"
android:layout_height="match_parent"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_margin="10dp"
android:scrollbars="vertical" />
instead of making it invisible remove it altogether by adding this to the layout:
android:visibility="gone"
and then set it to visible programmatically when you need it again.
Sorry for the elementary question but I can't find the solution:
When covering a button with a layout without elevation, it emerges over the layout because a button has a depth (negative depth, it points at the viewer).
So, if you have a
<FrameLayout... >
<Button.../>
<FrameLayout
id="#+id/fragmentsContainerOrAnything"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#C00F"
android:clickable="true"
android:focusable="true"
>
</FrameLayout>
</FrameLayout>
The button would show through the FrameLayout.... In this case, literally "out of the blue" because the button has depth and so it emerges over the layout, even though the layout is placed "upon" the button.
The question is:
How do I make the FrameLayout cover the underlying Button without fiddling with its elevation.
How do I make the button flat? Of course I can just set it back to the origins and call it "TextView". But is there a nicer way?
Thanks
Add your button inside FrameLayout
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</FrameLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#C00F"
android:clickable="true"
android:focusable="true" />
</FrameLayout>
I have made one layout where I have declared video on top and followed by text below it. Now I can make the text scroll but video stays still on top. I want the video + text to be scrollable.
To achieve this, I have done it somehow but I am not convinced that it is a good approach. I have created two XML files, in one I have put the video on top and text below it. And in second, I have called this layout and made it list view with scroll. Let me know a clean method to achieve scroll for video and text both.
Try this:
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<VideoView
android:id="#+id/video_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
</VideoView>
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="#string/your_text" >
</TextView>
</LinearLayout>
</ScrollView>
I want to develop an application which may have the overlapped views in an activity. So far i have developed the following view. which causes the one view at a time clickable and the other view does not catch the click listener. How can i have overlapped views with both view clickable, or if there is some other approach to get this,please suggest that idea. Thanks in advance for your help:
<RelativeLayout
android:id="#+id/squareFrameLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/imgBackground" >
<ViewStub
android:id="#+id/firstView"
android:layout_width="match_parent"
android:layout_height="match_parent"
layout="#layout/someView" />
<View
android:id="#+id/secondView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignTop="#id/firstView"
android:layout_alignBottom="#id/firstView"
/>
</RelativeLayout>
I have a layout similar to Foursquare (image), where a View (in their case, a map) is behind a ListView, but is visible because the first element is transparent.
I need the View behind the ListView to take touch and swipe events. Is there a way to make only that first invisible item of the ListView ignore these events and allow the events to propagate to the View behind it, but have the rest of the ListView items take the events as usual?
I'm just hoping I won't have to completely abandon the ListView and use a ScrollView instead, because I've already implemented a lot of ListView specific features.
ScrollView on the back will work normaly unless you click the button:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ScrollView
android:id="#+id/bottom"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/text"
android:text="asdfasdfa Put more text for testing sdfasdfasdfasdfasdfff
afdasdfasdfasdfasdfasdf
asdfasdfa"/>
</ScrollView>
<LinearLayout
android:id="#+id/top"
android:layout_height="match_parent"
android:layout_width="match_parent">
<Button
android:id="#+id/butt"
android:layout_height="100dp"
android:layout_width="200dp"
android:text="Test"/>
</LinearLayout>
</FrameLayout>
Both of the layers/frames have height and width set to match_parent (full screen in this case). And you can basicaly put anything you want into both of this layers as you need it.