I am using a swipe button from com.ebanx:swipe-button library in my application.
The swipe button in the emulator works perfectly, but when I compile the program (app-debug.apk) and install the program and start it, the swipe button doesn't appear for some reason.
What could be the reason. I developed the program from Android 8.
Thank you in advance for your help.
Here is the code: Here the activity_enter.xml
<?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="#drawable/plejadian"
android:orientation="horizontal"
android:visibility="visible"
tools:context=".EnterActivity"
tools:visibility="visible">
<com.ebanx.swipebtn.SwipeButton
android:id="#+id/swipe_button"
android:layout_width="563dp"
android:layout_height="100dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="469dp"
android:layout_marginTop="501dp"
android:layout_marginEnd="248dp"
android:layout_marginBottom="199dp"
app:button_background="#drawable/swipe_button_shape"
app:button_bottom_padding="10dp"
app:button_image_disabled="#drawable/ic_right_arrow_simple"
app:button_image_enabled="#drawable/ic_right_arrow_double"
app:button_left_padding="15dp"
app:button_right_padding="2dp"
app:button_top_padding="10dp"
app:inner_text=">> KÉRLEK LÉPJ BE >>"
app:inner_text_background="#drawable/swipe_inner_text_shape"
app:inner_text_bottom_padding="28dp"
app:inner_text_color="#C9DC17"
app:inner_text_size="25sp"
app:inner_text_top_padding="28dp" />
</RelativeLayout>
Here the java:
package com.example.firsttutorial;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.content.Intent;
import com.ebanx.swipebtn.SwipeButton;
public class EnterActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_enter);
SwipeButton swipe_button = findViewById(R.id.swipe_button);
swipe_button.setOnStateChangeListener(active -> startActivity(new Intent(EnterActivity.this,CompanyIntroActivity.class)));
}
}
Here the drawable library:
swipe_button_shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#00374E"/>
<corners android:radius="50dp"/>
</shape>
swipe_inner_text_shape.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="#00374E"/>
<corners android:radius="50dp"/>
</shape>
And here the com.ebanx:swipe-button library -> build.gradle(:app)
implementation 'com.ebanx:swipe-button:0.4.0'
So that’s it, I would really like to thank everyone for their help.
Regards
Peter
I was having an issue with the ebanx swipe button dependency not being recognized and fixed it by adding jcenter() under pluginManagement and dependencyResolutionManagement in the settings.gradle file
Related
I'm trying to build a simple app with GoogleMap API and I have custom tool bar.
The problem: I want to remove the default toolbar from the fragment.
activity .xml:
<LinearLayout
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=".activities.BillboardsMap"
android:orientation="vertical">
<include
android:id="#+id/tool_bar_back_billbo"
layout="#layout/tool_bar_back_billbo"
/>
<androidx.fragment.app.FragmentContainerView
android:id="#+id/map"
android:name="com.google.android.gms.maps.SupportMapFragment"
android:layout_width="match_parent"
android:layout_height="match_parent" />
</LinearLayout>
onCreate function:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityBillboardsMapBinding.inflate(layoutInflater)
setContentView(binding.root)
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
val mapFragment = supportFragmentManager
.findFragmentById(R.id.map) as SupportMapFragment
mapFragment.getMapAsync(this)
}
Is it possible to remove the toolbar with the title "BillboardsMap"?
Thanks in advance.
Try this -
STEP 1 -In style.xml or theme.xml add this custom new style.
<style name="NoToolbar" parent="Theme.MaterialComponents.Light.NoActionBar">
<item name="android:windowNoTitle">true</item>
</style>
STEP 2- In manifest.xml add this code for your activity.
<activity
....
android:theme="#style/NoToolbar" //ADD this line for your activity class
> </activity>
Android studio is sending me an error with this description "Incompatible types. Found: 'android.view.View', required: 'androidx.navigation.NavController'" to this piece of code (the part bold and italic):
package com.example.finalcsproject.HomePage;
import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.NavHostController;
import androidx.navigation.Navigation;
import android.os.Bundle;
import android.view.View;
import com.example.finalcsproject.R;
import com.google.android.material.bottomnavigation.BottomNavigationView;
public class HomePage extends AppCompatActivity {
NavController navController;
BottomNavigationView bottomNavigationView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home_page);
bottomNavigationView = findViewById(R.id.bottomNavigationView);
navController = ***findViewById(R.id.fragmentContainerView);***
}
}
Related:
XML file:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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"
tools:context=".HomePage.HomePage">
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottomNavigationView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/general"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:menu="#menu/buttom_menu"/>
<androidx.fragment.app.FragmentContainerView
android:id="#+id/fragmentContainerView"
android:name="androidx.navigation.fragment.NavHostFragment"
android:layout_width="409dp"
android:layout_height="673dp"
app:defaultNavHost="true"
app:layout_constraintBottom_toTopOf="#+id/bottomNavigationView"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:navGraph="#navigation/home_nav" />
</androidx.constraintlayout.widget.ConstraintLayout>
bottom menu:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="#+id/home4"
android:icon="#drawable/home_bm"
android:title="Home" />
<item
android:id="#+id/library"
android:icon="#drawable/book_bm"
android:title="My Library" />
<item
android:id="#+id/profile2"
android:title="Profile"
android:icon="#drawable/profilepic"/>
</menu>
Navigation:
<?xml version="1.0" encoding="utf-8"?>
<navigation 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/home_nav"
app:startDestination="#id/home4">
<fragment
android:id="#+id/home4"
android:name="com.example.finalcsproject.Home"
android:label="fragment_home"
tools:layout="#layout/fragment_home" />
<fragment
android:id="#+id/library"
android:name="com.example.finalcsproject.Library"
android:label="fragment_library"
tools:layout="#layout/fragment_library" />
<fragment
android:id="#+id/profile2"
android:name="com.example.finalcsproject.HomePage.Profile"
android:label="fragment_profile"
tools:layout="#layout/fragment_profile" />
</navigation>
How can I fix this issue. I would love some help, thank you so much!
Having read and tested numerous threads here to this topic (most threads to Java, not to Kotlin), I do not succeed in realizing and do not understand, what i do wrong
This is my Portrait test layout:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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">
<TextView
android:id="#+id/myText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="this is my Portraittext"
tools:layout_editor_absoluteX="173dp"
tools:layout_editor_absoluteY="344dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
I created landscape-xml by "create landscape.." This is the landscape-file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
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">
<TextView
android:id="#+id/myText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="this is my Portraittext"
tools:layout_editor_absoluteX="173dp"
tools:layout_editor_absoluteY="344dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
My Kotlin-file is quity simple:
package com.example.mytest
import android.content.res.Configuration
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import android.widget.TextView
import android.widget.Toast
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
}
override fun onConfigurationChanged(newConfig: Configuration) {
super.onConfigurationChanged(newConfig)
if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
Toast.makeText(this,"in portrait", Toast.LENGTH_SHORT).show()
} else {
if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
Toast.makeText(this,"in landscape", Toast.LENGTH_SHORT).show()
}
}
}
}
The Configuration does not change nor does any of the 2 "Toast"-statements fire. (In debug mode the onConfigurationChanged function is not entered
My AndroidManifest.xml is this:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.mytest">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/Theme.MyTest">
<activity android:name=".MainActivity"
android:label="#string/app_name"
android:configChanges="uiMode|orientation|screenSize|keyboardHidden">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
This means : quite standard, only extension the
android:configChanges="uiMode|orientation|screenSize|keyboardHidden">
I checked several entries in this line with orientation, screenSize, uiMode....., but nothing works. When I force the landscape-mode directly, display goes to landscape as expected.
What is wrong with my code?
I want to close my question. It works now without any change on my smartphone, but not in the emulator. May be strange, Sorry
I'm working on an android application, i added a new activity, that activity launches when i click on some button from my app, the IDE (android studio) isn't showing any errors, except that the name of the java class and the XML file i added is red (more like orange), nothing goes wrong till i click the button that launches the activity I'm talking about, it makes the app shut down.
here's my XML and java class that i added:
activity_bbel.xml
<?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:fitsSystemWindows="true"
android:background="#drawable/background"
tools:context="molfix.dev.molfix.Activities.Menu.BBEstLa.BBELActivity">
<android.support.design.widget.AppBarLayout
android:id="#+id/appbar"
android:background="#91d0f0"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="#drawable/toolbar_bb_e_l"
android:scrollbars="none"
app:popupTheme="#style/AppTheme.PopupOverlay"
android:weightSum="1">
<Button
android:layout_width="19dp"
android:background="#drawable/button_back"
android:layout_height="35dp"
android:id="#+id/b_back"/>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<Button
android:layout_width="250dp"
android:layout_height="55dp"
android:background="#drawable/button_conseils"
android:id="#+id/b_conseils"
android:layout_marginTop="125dp"
android:layout_below="#+id/appbar"
android:layout_centerHorizontal="true" />
<Button
android:layout_width="250dp"
android:layout_height="55dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="#drawable/button_carnet_sante"
android:id="#+id/b_carnet_sante"
android:layout_marginTop="20dp"
android:layout_below="#+id/b_conseils"
android:layout_centerHorizontal="true" />
BBELActivity.java
package molfix.dev.molfix.Activities.Menu.BBEstLa;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import molfix.dev.molfix.Activities.Menu.BBEnRoute.BBERActivity;
import molfix.dev.molfix.R;
/**
* Created by AminLRoy on 21-Jul-17.
*/
public class BBELActivity extends AppCompatActivity{
Button b_back;
String pseudo;
#Override
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_bbel);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("");
setSupportActionBar(toolbar);
Intent intent = getIntent();
pseudo = intent.getExtras().getString("pseudo");
b_back =(Button) findViewById(R.id.b_back);
b_back.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
BBELActivity.this.finish();
}
});
}
}
Any ideas about how to solve this?
I found the solution, the problem was that the new Activity added wasn't mentioned in the manifest file.
Excuse the title - not sure how to word this question.
I created a file called rectangle.xml inside res/drawable. It is an extremely basic rectangle shape, the I'm using with an ImageView within a custom listview.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#FF0000" />
<corners android:radius="4dp"/>
</shape>
Using it like so:
<ImageView
android:id="#+id/row_colorRect"
android:layout_width="24dp"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="#drawable/rectangle" />
I want to be able to access that rectangle's solid property so I can change its color on the fly. I can't access that property through the ImageView .. so I imagine I have to somehow dig into the children of the ImageView, find the shape, and change it that way.
How do I go about this?
Thanks!
Just tried it and I managed to do it.
ImageView imageView = (ImageView) findViewById(R.id.row_colorRect);
((GradientDrawable) imageView.getDrawable()).setColor(Color.RED);
Accessing the ImageView GradientDrawable, that represents your rectangle.xml resource, you can change its solid color, among other attributes.
Try this way,hope this will help you to solve your problem.
shape.xml (Drawable)
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" android:shape="rectangle">
<solid android:color="#FF0000" />
<corners android:radius="4dp"/>
</shape>
main.xml
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<ImageView
android:id="#+id/imageView"
android:layout_width="100dp"
android:layout_height="100dp"
android:background="#drawable/shape"/>
</LinearLayout>
MyActivity.java
public class MyActivity extends Activity {
private ImageView imageView;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
imageView = (ImageView) findViewById(R.id.imageView);
imageView.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
GradientDrawable sd = (GradientDrawable) imageView.getBackground().mutate();
sd.setColor(Color.parseColor("#CCC111"));
sd.invalidateSelf();
}
});
}
}