I used compile 'com.sdsmdg.harjot:rotatingtext:1.0.2' in Android app. It is working in Android Marshmallow API 22 and lower versions. To be more precise, It rotates text with Animation. In Android with Api level 22 and lover it is showing text with Animation. But higher versions don`t support. What should I do to be supported in all versions of Android devices. Please Help.
Here is Source Code:
MainActivity.java
package com.example.abdusoli.rotatingtext;
import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.animation.BounceInterpolator;
import android.widget.Button;
import android.text.TextUtils;
import android.view.View;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.DecelerateInterpolator;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.Spinner;
import com.sdsmdg.harjot.rotatingtext.RotatingTextWrapper;
import com.sdsmdg.harjot.rotatingtext.models.Rotatable;
import java.util.ArrayList;
import java.util.List;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/Raleway-Light.ttf");
Typeface typeface2 = Typeface.createFromAsset(getAssets(), "fonts/Reckoner_Bold.ttf");
RotatingTextWrapper rotatingTextWrapper = (RotatingTextWrapper) findViewById(R.id.custom_switcher);
rotatingTextWrapper.setSize(35);
rotatingTextWrapper.setTypeface(typeface2);
Rotatable rotatable = new Rotatable(Color.parseColor("#FFA036"), 2000, " ", "Word01", "Word02");
rotatable.setSize(35);
rotatable.setAnimationDuration(600);
rotatable.setTypeface(typeface);
rotatable.setInterpolator(new BounceInterpolator());
rotatingTextWrapper.setContent("This is ?", rotatable);
}
}
gradle.build(Module: app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.abdusoli.rotatingtext"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:cardview-v7:26.1.+'
compile 'com.flaviofaria:kenburnsview:1.0.7'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.sdsmdg.harjot:rotatingtext:1.0.2'
}
Currently the library does not support higher versions
Issue has been raised on the repo in github
Related
I am trying to import androidx.navigation.ui.AppBarConfiguration and androidx.navigation.ui.NavigationUI into my main activity.
Here is my main activity:
package com.example.cyticketclient;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import androidx.appcompat.app.AppCompatActivity;
import androidx.navigation.NavController;
import androidx.navigation.Navigation;
import androidx.navigation.ui.AppBarConfiguration;
import androidx.navigation.ui.NavigationUI;
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
BottomNavigationView navView = findViewById(R.id.nav_view);
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
R.id.navigation_sales,
R.id.navigation_messages,
R.id.navigation_forum,
R.id.navigation_profile).build();
}
}
I am getting the error
Cannot resolve symbol 'ui'
How do I get androidx.navigation.ui.AppBarConfiguration and androidx.navigation.ui.NavigationUI to import?
Here is my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.cyticketclient"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.navigation:navigation-runtime:2.3.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.android.volley:volley:1.1.1'
}
Classes in androidx.navigation.ui are in the navigation-ui dependency as per the Navigation declaring dependencies
implementation 'androidx.navigation:navigation-ui:2.3.0'
I'm using Kotlint 1.3.50 and Android Studio 3.4
I have my code
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
my_txt.text = "ABC"
}
}
Any my layout as below
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="#+id/my_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello World!"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout>
Everything compiles fine if they are in the same module.
However, if I move my layout to an android library, with gradle as below
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 21
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
I can still import kotlinx.android.synthetic.main.activity_main.* and Android Studio doesn't complaint. But, when I compile, it complaints
Unresolved reference: activity_main
Unresolved reference: my_txt
Looks like the kotlin-extension can't cross use layout from another library?
If I change to findViewById<TextView>(R.id.my_txt).text = "XYZ", it works fine.
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.widget.TextView
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
findViewById<TextView>(R.id.my_txt).text = "XYZ"
}
}
I an learning android studio and was trying to make a simple app using fragments but I am getting the below error.
error- Cannot resolve method 'setupWithViewPager(androidx.viewPager.widget.ViewPager)'
My Code:
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;
import android.os.Bundle;
import android.widget.TableLayout;
public class MainActivity extends AppCompatActivity {
private TableLayout tableLayout;
private ViewPager viewPager;
private ViewPagerAdapter adapter;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tableLayout= (TableLayout) findViewById(R.id.tab_layout);
viewPager=(ViewPager) findViewById(R.id.pager_id);
adapter=new ViewPagerAdapter(getSupportFragmentManager());
adapter.AddFragement(new Fragment_call(),"Call");
adapter.AddFragement(new FragmentContact(),"Contact");
adapter.AddFragement(new FragmentFav(),"Favourite");
viewPager.setAdapter(adapter);
tableLayout.setupWithViewPager(viewPager);
}
}
My gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.ass"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//compile 'com.android.support:design:25.3.1'
}
Any help would be appreciated.
Didn't you mean TabLayout instead TableLayout?
If so, change tableLayout = (TableLayout) findViewById(R.id.tab_layout); to TabLayout tableLayout = findViewById(R.id.tab_layout);
tableLayout= (TableLayout) findViewById(R.id.tab_layout);
tableLayout.setupWithViewPager(viewPager);
The android.widget.TableLayout doesn't have the method setupWithViewPager.
Maybe you are looking for the com.google.android.material.tabs.TabLayout.
It requires the Material Components library as dependency:
implementation 'com.google.android.material:material:1.1.0'
It's TabLayout and not TableLayout. These are two different things.
After i add an activity,‘NavigationVew’ in the previous activity display error that "can't resolve drawable symbol
package com.eight.zhan.kitchen;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.NavigationView;
import android.support.design.widget.Snackbar;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import com.mancj.materialsearchbar.MaterialSearchBar;
public class Main2Activity extends AppCompatActivity
implements NavigationVew.OnNavigationItemSelectedListener
,MaterialSearchBar.OnSearchActionListener {
}
This is my build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.eight.zhan.kitchen"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}}dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:support-vector-drawable:25.3.1'
compile 'com.github.mancj:MaterialSearchBar:0.7'
compile 'com.android.support:support-v4:25.3.1'
}
The error message diaplay "package NavigationVew does not exist"
why?
i think need following two steps
Clean Project.
Rebuild Project.
NavigationVew mean nothing,it should be NavigationView.
This question already has answers here:
Can I make an Android library which contains resource files?
(1 answer)
How to manually include external aar package using Gradle for Android
(26 answers)
Closed 7 years ago.
I am trying to create library project and used library code and resource to my other application, I can successfully get library activity or method which was not using any resource, but getting error when I try to use resource in activity or any method.
Here is my code.
package com.dhl.lib;
import android.app.ActionBar;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.InputType;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Toast;
public class AdditionActivity extends AppCompatActivity implements View.OnClickListener {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initUI();
}
private void initUI() {
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
linearLayout.setOrientation(LinearLayout.VERTICAL);
final EditText edtFirst = new EditText(this);
edtFirst.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
edtFirst.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
final EditText edtSecond = new EditText(this);
edtFirst.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
edtFirst.setInputType(InputType.TYPE_NUMBER_FLAG_DECIMAL);
Button btn = new Button(this);
btn.setLayoutParams(new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
btn.setText("Add");
btn.setBackground(getResources().getDrawable(R.mipmap.ic_launcher));
btn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
Toast.makeText(AdditionActivity.this, "==> " + (Integer.parseInt(edtFirst.getText().toString().trim()) + Integer.parseInt(edtSecond.getText().toString().trim())), Toast.LENGTH_SHORT).show();
}
});
linearLayout.addView(edtFirst);
linearLayout.addView(edtSecond);
linearLayout.addView(btn);
setContentView(linearLayout);
}
#Override
public void onClick(View v) {
}
}
Here another class which used resource
package com.dhl.lib;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;
public class About {
public static void show(Activity activity, String aboutText,
String okButtonText) {
String versionNumber = "unknown";
Drawable icon = null;
String appName = "unknown";
View about;
TextView tvAbout;
try {
LayoutInflater inflater = activity.getLayoutInflater();
about = inflater.inflate(R.layout.about, null);
tvAbout = (TextView) about.findViewById(R.id.ca_tutortutor_aboutText);
} catch (InflateException e) {
about = tvAbout = new TextView(activity);
}
tvAbout.setText(Html.fromHtml(aboutText));
tvAbout.setMovementMethod(LinkMovementMethod.getInstance());
new AlertDialog.Builder(activity)
.setTitle(appName + " " + versionNumber)
.setIcon(icon)
.setPositiveButton(okButtonText, null)
.setView(about)
.show();
}
}
** XML Resource of About.xml **
<?xml version="1.0" encoding="utf-8"?>
<scrollview xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/ca_tutortutor_aboutView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
tools:context="com.dhl.lib.About">
<linearlayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal"
android:padding="5dp">
<textview
android:id="#+id/ca_tutortutor_aboutText"
android:layout_width="wrap_content"
android:layout_height="fill_parent"></textview>
</linearlayout>
</scrollview>
** Manifest of Lib Project **
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dhl.lib">
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:supportsRtl="true"
android:theme="#style/AppTheme">
<activity android:name=".AdditionActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
** app build.gradle **
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}
From that lib I can successfully get access of AdditionActivity on my Project but When I try to access About, getting error of java.lang.NoClassDefFoundError: Failed resolution of: Lcom/dhl/lib/R$layout;
Where I made mistake ? I can't found that point.
Here Is my Application app build.gradle which used library project
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.addtion.lib"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
provided files('libs/addition.jar')
}
** Application Main Activity Class **
public class MainActivity extends AppCompatActivity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button btn = (Button) findViewById(R.id.btn_callAdd);
btn.setText("Call Addition Activity");
btn.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
startActivity(new Intent(MainActivity.this, AdditionActivity.class));
}
});
((Button) findViewById(R.id.btn_callAlert)).setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
About.show(MainActivity.this, "Hello From Application", "Ok");
}
});
}
}