Video background on entire screen - android

I want to have a video background on my entire screen. Everything works correctly in java: it loops etc. The problem might be in xml.
Currently I have video on a top of the screen, it looks like this: (Video is perfeclty fitted in edges)
While my purpose is to have it entirely in my screen:
Please what should i make my xml look like to achieve my goal. Thanks.
XML:
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/home_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<VideoView
android:id="#+id/surface"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</FrameLayout>

First you need to set the orientation to landscape since you said you purpose is in landscape mode
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); // add it below super.oncreate
If this code not working check out this link
or your could set the orientation in manifest just google it
And change this in your xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/home_container"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<VideoView
android:id="#+id/surface"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
/>
</FrameLayout>

Related

Change the quality of an ImageView

I'm trying to make a splash screen, I'm doing that with react native, but I'm using android studio to create the style.
First of all, I'm following this video that uses this library.
I have the following code of my splash screen:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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/primary"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
>
<ImageView
android:layout_width="100dp"
android:layout_height="100dp"
android:src="#drawable/launch_screen"
android:scaleType="centerCrop" />
</LinearLayout>
</RelativeLayout>
It looks like this:
As you can see, the quality of the logo is low, and I would like to make it better.
My drawable folder is the following:
Thanks!
It seems that your launch_screen.png file has a small resolution.
Change that file with bigger resolution with better quality.

Android-Last item of the ListView is not visible

I have added the ListView inside ViewPager, as soon as the page is loaded the first tab is selected and the last item of the list does not show up for the first time, its becoming visible when I go to next tab and come back. I would like to see all the items of the listview when its loaded for the first time. Please help me to fix this problem.
This is the xml for the listview -
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/listview_categories"
android:layout_width="fill_parent"
android:divider="#color/light_gray_a1"
android:dividerHeight="0.667dp"
android:background="#color/white"
android:layout_height="fill_parent" />
</RelativeLayout>
add bottom padding like this and change fill_parent to match_parent
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="#+id/listview_categories"
android:layout_width="match_parent"
android:divider="#color/light_gray_a1"
android:dividerHeight="0.667dp"
android:paddingBottom="40dp"
android:background="#color/white"
android:layout_height="match_parent" />
</RelativeLayout>
I had this issue. Just now I solved it. Look for android:layout_weight in all the Layouts you used and if it is set some non zero values like android:layout_weight="1" or android:layout_weight="0.91", then set them to zero like this,
android:layout_weight="0"

Align element in corner of round Wear device

I am trying to align an Object into the corner of my round_layout for a round android wear device.
As you can see here:
The digitalclock will be out of bounds.
I've seen the android wear documentation at the google IO 2014, and some guy showed, that there's a line of code, in order to align the objects correctly.
I want the digitalclock to be in the top left corner, but not out of the screen.
Has anyone got a suggestion?
Here's the XML file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MyActivity"
tools:deviceIds="wear_round">
<DigitalClock
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#color/text"
android:textSize="20sp"/>
</RelativeLayout>
Edit:
My xml layout file looks like this right now, for the round activity:
<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.BoxInsetLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1234567890"
app:layout_box="top"/>
</android.support.wearable.view.BoxInsetLayout>
As You can see, I tried to use the BoxInsetLayout, but still, the output is following:
Although I used
app:layout_box="top"
The TextView is out of the screen's bounds. What have I overseen?
According for things shown on Google IO 2014 you should use BoxInsetLayout:
Check out this video <- about 6:04
You can see the usage of BoxInsetLayout in DelayedConfirmation sample code. Here is a content of main_activity.xml file:
<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.BoxInsetLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#color/grey"
app:layout_box="top">
[...]
</LinearLayout>
</android.support.wearable.view.BoxInsetLayout>
You can set the app:layout_box to following values: left|top|right|bottom or all. You can use all in your case, then all content will be kept within the box on every side. The effect for this layout is ignored when app is running on square watch.
EDIT:
I've just tested the code you've posted as "doesn't work":
<?xml version="1.0" encoding="utf-8"?>
<android.support.wearable.view.BoxInsetLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="match_parent"
android:layout_width="match_parent">
<TextView android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1234567890"
app:layout_box="all"/>
</android.support.wearable.view.BoxInsetLayout>
With activity:
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
I've told you to use the all value in layout_box, but even with top it works as should:
app:layout_box="top": (only offset from top)
app:layout_box="all": (offset from any side)

Why is my Webview resizing itself?

I'm a noob to android development and my webview resizes itself whenever i try to play video. In order to make the webview play video i had to add the line of code:
youtube.getSettings().setPluginState(PluginState.ON);
In my layout, I have my webview above a listview. However, now when the webview plays video it becomes fullscreen and covers listview. this was not happening before i added the line above. How do I stop my webview from resizing itself? Any help is greatly appreciated?
Here is my layout
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:id="#+id/LLvideos" >
<WebView
android:id="#+id/webViewyoutube"
android:layout_width="match_parent"
android:layout_height="350dp" >
</WebView>
<!-- List view -->
<ListView
android:id="#+id/videolist"
android:layout_width="fill_parent"
android:layout_height="200dp"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:divider="#00000000"
android:dividerHeight="0dp" >
</ListView>
Here is my video link
youtube.loadUrl("http://link.brightcove.com/services/player/bcpid1683318714001?bckey=AQ~~,AAAAC59qSJk~,vyxcsD3OtBPHZ2UIrFX2-wdCLTYNyMNn&bclid=1644543007001&bctid=1858951133001");
Sounds like you are have a scaling issue. Try youtube.setInitialScale(50). This should work.
Try setting the webview layout like this:
webview.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);

Integrating Ads in a Game

i have a 2D game which has my custom ViewPanel which handles all the drawings (i don't have android Button elements, all my game controls are painted/handled internally).
this is my main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
</LinearLayout>
and this is my activity's onCreate() main code:
viewPanel = new ViewPanel(this);
setContentView(viewPanel);
from this point my ViewPanel handles all the drawings/events.
Now,
i want to integrate Ads (Mobclix), and this is how i do it:
setContentView(R.layout.mobclix_advertising_view);
Mobclix.onCreate(this);
adview_banner = (MobclixMMABannerXLAdView) findViewById(R.id.advertising_banner_view);
adview_banner.addMobclixAdViewListener(this);
adview_banner.setRefreshTime(30000);
adview_banner.getAd();
HOWEVER! it seems i can either setContentView on my ViewPanel OR on "advertising_banner_view" not both. So basically either i see my game drawing OR the advertising bar.
How can i see them both?
Try this:
my_layout.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_height="fill_parent">
</FrameLayout>
Now just use my_layout as you main layout, and call addView twice on it, once with your ViewPanel and once with your AdView. You can set the gravity of the adview to float it where ever you want on the screen.
You can do this:
game.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<com.package.ViewPanel />
<com.package.MobclixMMABannerXLAdView />
</LinearLayout>
in your code:
setContentView(R.layout.game);
than you can use findviewbyid to get those views.

Categories

Resources