black bar at bottom Revmob ad android - java

I am using revmob banner ad in my app. The problem I am facing is:
Before banner display at bottom of layout view "Black bar is showing" when i click it hides or remove from the view. I don't know why. Please tell me how to solve this issue.
Code is this
RevMobBanner banner;
void showBanner() {
revmob = RevMob.start(this); // RevMob Media ID configured in the AndroidManifest.xml file
banner = revmob.createBanner(this);
runOnUiThread(new Runnable() {
#Override
public void run() {
ViewGroup view = (ViewGroup) findViewById(R.id.adLayout);
view.addView(banner);
}
});
}
Xml file:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="#+id/adLayout"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:visibility="visible">
</RelativeLayout>
</RelativeLayout>
showbanner()// calling from activity
Thanks.

Related

Dialog box buttons not visible on smaller screens and resolutions?

I'm trying to show a tutorial when user runs the app for the first time, by using dialog boxes. However, the "back" and "next" buttons aren't visible on smaller screens and/or resolutions, so the user can't proceed with the tutorial.
I tried making the dialog box a ScrollView but it didn't help, buttons are still invisible. What's the best way to resolve this? Thanks in advance!
EDIT: here's an example of the first dialog shown to user:
AlertDialog.Builder w1 = new AlertDialog.Builder(this);
LayoutInflater w1Inflater = LayoutInflater.from(this);
View w1Layout = w1Inflater.inflate(R.layout.dialog, null);
ImageView image1 = (ImageView) w1Layout.findViewById(R.id.my_image);
image1.setImageResource(R.drawable.ic_launcher);
w1.setView(w1Layout);
w1.setTitle("Welcome");
w1.setMessage(Html.fromHtml("Before you start using the app, get familiar with the User Interface!"));
w1.setCancelable(false);
w1.setPositiveButton("Next", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
switch3();
num = 3;
((ViewGroup)w1Layout.getParent()).removeView(w1Layout);
}
});
And here's the dialog.xml:
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<ImageView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_gravity="center"
android:id="#+id/my_image"/>
</LinearLayout>
</ScrollView>

How do I inflate dialog at the bottom of my layout?

My swipe to dismiss dialog is currently showing at the center of my layout which matches the parent's width. No left/right margins. I want to place it on the bottom.
This is my XML layout:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/layout_fmcg_popup"
android:layout_width="match_parent"
android:layout_height="wrap_content"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_gravity="bottom"
android:layout_weight="1"
android:background="#drawable/button_border">
<android.support.constraint.ConstraintLayout
android:id="#+id/main_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="17dp"
android:layout_marginTop="13dp"
android:layout_marginEnd="17dp"
android:layout_marginBottom="13dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
// other code goes here
</android.support.constraint.ConstraintLayout>
</android.support.constraint.ConstraintLayout>
This is the code for swipe to dismiss dialog. I am currently using a swipe to dismiss dialog library.
View dialog = LayoutInflater.from(this).inflate(R.layout.dialog_fmcg_popup, null);
TextView tvfmcg2 = dialog.findViewById(R.id.tv_fmcg2);
tvfmcg2.setText(message);
swipeDismissDialog = new SwipeDismissDialog.Builder(this)
.setView(dialog)
.setOnSwipeDismissListener(new OnSwipeDismissListener() {
#Override
public void onSwipeDismiss(View view, SwipeDismissDirection direction) {
Preferences.setString(Prefkey.last_qualified_fmcg_voucher_on_remove, message);
}
})
.setFlingVelocity(0)
.setOverlayColor(0)
.build()
.show();
}
You can try below code this will show the dialog at the bottom of the screen:
Dialog dialog
//code to initialize dialog here
Window window = dlg.getWindow();
WindowManager.LayoutParams wlp = window.getAttributes();
wlp.gravity = Gravity.BOTTOM;
wlp.flags = WindowManager.LayoutParams.FLAG_DIM_BEHIND;
window.setAttributes(wlp);

android gallery app with sliding pictures

As in the title. I want to have grid of pictures which consists of 2 columns and every picture must have the same dimensions. The user should be able to click on each picture to enter the full screen mode and then slide pictures from left to right (full sized pictures in that mode). By far, I made a grid of clickable elements but without functionality of sliding them. Here is my code:
activity_main.xml
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.example.miki.androidtwo.MainActivity">
<GridView
android:id="#+id/grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:numColumns="2"
android:scrollbars="vertical"
android:gravity="center">
</GridView>
</RelativeLayout>
activity_full_image.xml
<?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"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:paddingRight="0dp"
android:paddingTop="0dp"
tools:context="com.example.miki.androidtwo.FullImageActivity">
<ImageView
android:id="#+id/image"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:id="#+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="I want to see other doggos" />
</RelativeLayout>
MainActivity.java
public class MainActivity extends AppCompatActivity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GridView gridView = (GridView) findViewById(R.id.grid);
// Instance of ImageAdapter Class
gridView.setAdapter(new ImageAdapter(this));
/**
* On Click event for Single Gridview Item
* */
gridView.setOnItemClickListener(new OnItemClickListener() {
#Override
public void onItemClick(AdapterView<?> parent, View v,
int position, long id) {
// Sending image id to FullScreenActivity
Intent i = new Intent(getApplicationContext(), FullImageActivity.class);
// passing array index
i.putExtra("id", position);
startActivity(i);
}
});
}
}
Other classes are FullImageActivity and ImageAdapter; they are pretty obvious and simple so I won't post them.
How can I implement this sliding pictures functionality?
How can i determine dimensions of pictures in a grid that will be independent of the device?
Actually I think I hard-coded it with the line:
imageView.setLayoutParams(new GridView.LayoutParams(480,402));
If you want to slide the images while they are not full screen, you can use a HorizontalScrollView, or if you want to slide them while they are fullscreen, you can use a ViewPager, along with a PagerAdapter.
So to populate the grid imageView.setLayoutParams is fine to use for setting the size of each imageview like the way you did. When a user clicks on an image, you are going to go to a new Activity that is setup with a ViewPager and a PagerAdapter. This way the user can slide through fullscreen images.

Android Fullscreen Fragment Dialog Background Clickable

I have fullscreen fragment dialog. While it is showing, background objects can be clickable or interact with user. how do i avoid this?
Here is piece of code how i show dialog:
MainActivity.java
FullScreenFrDialog fr = new FullScreenFrDialog();
FragmentTransaction tr = getSupportFragmentManager().beginTransaction();
tr.add(android.R.id.content, fr, FR_TAG).commit();
FullScreenFrDialog.java
public class FullScreenFrDialog extends DialogFragment {
#Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.dialog, container, false);
return view;
}
}
dialog.xml
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#CCFFFFFF" >
<ImageView
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="#drawable/ic_launcher" />
</FrameLayout>
main_activity.xml
<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" >
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
</RelativeLayout>
This button clickable, while dialog is showing.
Thanks in advance.
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:background="#CCFFFFFF" >
Make the parents clickable true, hope this will help you.
In your onCreate() simply call setCancelable(false). This will prevent the dialog from closing if tapped outside the dialog and will also prevent tap events to the elements beneath
EDIT
Alternatively you can call setCanceledOnTouchOutside(false) if you want it to be dismissed with a back button press but still prevent touches to elements beneath

WebView in background is still clickable when ProgressBar is shown

I have my android webView app working nice. It also shows the ProgressBar while loading the url and hides it when finish the load with a beautiful effect cause I put some alpha in the ProgressBar layout to see webView in the background. I followed this example..
My problem is: webView is still clickable.
MyManifest.xml: i have all permissions needed I think...
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="21" />
main_layout.xml
<?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="fill_parent"
android:layout_height="fill_parent"
android:id="#+id/mainLayout"
tools:context="com.siconet.axa.MainActivity" >
<RelativeLayout
android:id="#+id/loadingPanel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true" >
<ProgressBar
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:indeterminate="true" />
</RelativeLayout>
<WebView
android:id="#+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</RelativeLayout>
Then I show/hide progressbar in the client and I need to avoid webView from being clicked:
webViewClient.java
#Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
{
loadingFinished = false;
// this works like charm
activity.findViewById(R.id.loadingPanel).setVisibility(View.VISIBLE);
activity.findViewById(R.id.webView).setAlpha(0.3f);
// this is not working :(
activity.findViewById(R.id.loadingPanel).setClickable(true);
activity.findViewById(R.id.webView).setClickable(false);
super.onPageStarted(view, url, favicon);
}
#Override
public void onPageFinished(WebView view, String url)
{
// control of the loading options....
if (loadingFinished && !redirect) {
activity.findViewById(R.id.loadingPanel).setVisibility(View.GONE);
activity.findViewById(R.id.webView).setAlpha(1f);
// not working again :(
activity.findViewById(R.id.loadingPanel).setClickable(false);
activity.findViewById(R.id.webView).setClickable(true);
}
}
I also tried with requestFocus():
activity.findViewById(R.id.loadingPanel).requestFocus();
And adding listeners to the views:
mWebView.setOnTouchListener(new OnTouchListener() { // declare listener...
Any idea of why is this happening???
Add this attribute to your ProgressBar element in XML:
android:clickable="true"
Change your RelativeLayout (the ProgressBar View parent) attributes to:
<RelativeLayout
android:id="#+id/loadingPanel"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true"
android:layout_centerInParent="true" >
This will make your RelativeLayout to cover your whole layout (not just 100dpx100dp) and to receive the clicks while its visible.

Categories