ok, so before I've asked this question, I've looked at:
How to remove unwanted overlapping in android
Tabs at bottom overlapping with the list view
Android bottom navigation bar overlapping Spinner. Set Spinner dropdown height / margin
Bottom button bar overlaps the last element of Listview!
However I haven't seen what I would think to be a fix for my particular situation. So here's my problem: I'm writing a custom SurfaceView that will display an image on-screen. In that SurfaceView I am drawing an image to the bottom right-hand corner. Here is the code:
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Point;
import android.os.Build;
import android.os.Bundle;
import android.view.Display;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.WindowManager;
public class demosf extends Activity {
OurView v;
int Measuredwidth;
int Measuredheight;
WindowManager w;
Bitmap whatever;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Measuredwidth = 0;
Measuredheight = 0;
getScreenWidthAndHeight();
whatever = BitmapFactory.decodeResource(getResources(), R.raw.dragarrow);
v = new OurView(this);
setContentView(v);
}
public class OurView extends SurfaceView implements Runnable {
Thread t = null;
SurfaceHolder holder;
boolean isItOK;
public OurView(Context context) {
super(context);
holder = getHolder();
}
@Override
public void run() {
while (isItOK) {
try {
Thread.sleep((long) 50);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (!holder.getSurface().isValid()) {
continue;
}
Canvas c = holder.lockCanvas();
c.drawARGB(255, 0, 0, 0);
c.drawBitmap(whatever, ((float) Measuredwidth - (float) whatever.getWidth()), ((float) Measuredheight - (float) whatever.getHeight()), null);
holder.unlockCanvasAndPost(c);
}
}
public void pause() {
isItOK = false;
while (true) {
try {
t.join();
} catch (InterruptedException e) {
e.printStackTrace();
}
break;
}
t = null;
}
public void resume() {
isItOK = true;
t = new Thread(this);
t.start();
}
}
@Override
protected void onPause() {
super.onPause();
v.pause();
}
@Override
protected void onResume() {
super.onResume();
v.resume();
}
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public void getScreenWidthAndHeight() {
Point size = new Point();
w = getWindowManager();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
w.getDefaultDisplay().getSize(size);
Measuredwidth = size.x;
Measuredheight = size.y;
} else {
Display d = w.getDefaultDisplay();
Measuredwidth = d.getWidth();
Measuredheight = d.getHeight();
}
}
}
and just to be thorough, here's the manifest too:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.something"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.something.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.something.demosf"
android:label="@string/app_name"
android:screenOrientation="landscape"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
>
<intent-filter>
<action android:name="com.example.something.DEMO" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
now the problem I seem to be having, is that on my Nexus 7 this works out exactly as I'd expect. However on my friends Toshiba Thrive, the bottom of the image is cut off by the bar on the bottom. Here's the comparison:
The Nexus7 is on the right, the Thrive is on the left. So my question is: what exactly is happening, and how can I fix this? (preferably for all Android versions)
Oh, side question: what exactly is that bottom bar even called? lol
EDIT: I'm aware that it's not the best code, I'm simply using this code to demonstrate what's happening and perhaps find a different approach to my "getScreenWidthAndHeight()" method that accounts for this odd overlap in the devices it occurs in