How to create Slanted TextView in Android | Android Studio | Stackoverflow

Android Slanted TextView .


Preview

预览

Gradle

compile 'com.haozhang.libary:android-slanted-textview:1.1'


XML Layout

<com.haozhang.lib.SlantedTextView
    android:layout_width="80dp"
    android:layout_height="80dp"
    android:gravity="center"
    app:slantedBackgroundColor="@color/secondary_text"
    app:slantedLength="40dp"
    app:slantedMode="left"
    app:slantedText="IOS"
    app:slantedTextColor="@color/primary"
    app:slantedTextSize="16sp"
    />


Java


    SlantedTextView stv = (SlantedTextView) findViewById(R.id.test);

    stv.setText("PHP")
            .setTextColor(Color.WHITE)
            .setSlantedBackgroundColor(Color.BLACK)
            .setTextSize(18)
            .setSlantedLength(50)
            .setMode(SlantedTextView.MODE_LEFT);


Attributes

注意

SlantedMode
SlantedMode

License
Copyright 2016 Hand HaoZhang

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

How to launch Android app from Dialer

Android give facility to developer and user to use a flexible and open-source platform. In Android, you can take permission for use of Dialer and also the Broadcast Receiver for listening something happened or not.

So, today I am sharing with you how to open Apps through Dialer. Dailing some predefine code | Number which opens our Application.

How to launch Android app from Dialer
How to launch Android app from Dialer

Here Some Java code which listening...

public class DialReceiver extends BroadcastReceiver
{
    @Override
  public void onReceive(Context context, final Intent intent) {

    if (intent.getAction().equals(android.content.Intent.ACTION_NEW_OUTGOING_CALL)) {
        String phoneNumber = intent.getExtras.getString("Intent.EXTRA_PHONE_NUMBER");

             if(phoneNumber.equals("*#588637#")) { 
             //do your stuff
            }
} } }

And use Manifest File to get your Permision for Access Apps in your Mobile Installed.




How to know FingerPrint feature available in android? | FingerPrint Feature code too check your mobile Supported or not ?

In Android Version 6.0 Android Marshmallow FingerPrint Features Enable. So, how you code your device support or not ? How to check the FingerPrint code works or not here is the solution for the FingerPrint check is your mobile support or not ?




You know how to get all permission for FingerPrint and how to use but how to know devices support FingerPrint or not ? below is some of code which helps you to know device support or not ?

How to know FingerPrint feature available in android? | FingerPrint Feature code too check your mobile Supported or not ?
How to know FingerPrint feature available in android? | FingerPrint Feature code too check your mobile Supported or not ?


So, Let get Started for FingerPrint...

First, you have to get permission from the Manifest file..

<uses-permission android:name="android.permission.USE_FINGERPRINT"/>


Example 1


if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
    Toast.makeText(this, "Finger print not supported", Toast.LENGTH_SHORT).show();
}

Example 2


FingerprintManager fingerprintManager = (FingerprintManager) getSystemService(Context.FINGERPRINT_SERVICE);
if (!fingerprintManager.isHardwareDetected()) {
    // Device doesn't support fingerprint authentication
    Toast.makeText(this, "Device doesn't support fingerprint authentication", Toast.LENGTH_SHORT).show();
} else if (!fingerprintManager.hasEnrolledFingerprints()) {
    // User hasn't enrolled any fingerprints to authenticate with
   Toast.makeText(this, "User hasn't enrolled any fingerprints to authenticate with", Toast.LENGTH_SHORT).show();
} else {
   // Everything is ready for fingerprint authentication
   Toast.makeText(this, "Everything is ready for fingerprint authentication", Toast.LENGTH_SHORT).show();
}


If you have any Queries regarding the API comment below also share with your Friends

Floating Labels : Material Design Tips

Floating labels
From google material design documentation.
When the user engages with the text input field, the floating inline labels move to float above the field.

How to add?

I. In your build.gradle add latest appcompat and design libraries.
dependencies {  
    compile 'com.android.support:appcompat-v7:X.X.X' // where X.X.X version
    compile 'com.android.support:design:X.X.X' // where X.X.X version
}
II. Make your activity extend android.support.v7.app.AppCompatActivity.
public class MainActivity extends AppCompatActivity {  
    ...
}
III. Declare your EditText inside any layout.xml file and wrap it with TextInputLayout.
<android.support.design.widget.TextInputLayout  
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/Title" />

</android.support.design.widget.TextInputLayout>  
Both widgets TextInputLayout and EditText have android:hint attribute, you can use any of them.

How to style?

Floating labels
I. Declare custom styles in your styles.xml file.
<!--Floating label text style-->  
<style name="MyHintText" parent="TextAppearance.AppCompat.Small">  
    <item name="android:textColor">@color/pink</item>
</style>

<!--Input field style-->  
<style name="MyEditText" parent="Theme.AppCompat.Light">  
    <item name="colorControlNormal">@color/indigo</item>
    <item name="colorControlActivated">@color/pink</item>
</style>  
II. Apply this styles to your TextInputLayout via app:hintTextAppearance attribute and to EditText via android:theme attribute.
<android.support.design.widget.TextInputLayout  
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:hintTextAppearance="@style/MyHintText">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/Title"
        android:theme="@style/MyEditText" />

</android.support.design.widget.TextInputLayout>  

User Input Errors : Material Design Tips

Floating labels
From google material design documentation.
Help users fix input errors as soon as they are detected. Disable the submission of a form if errors are detected, and if detected only after form submission, clearly explain the error and how to fix it.

How to add?

I. In your build.gradle add latest appcompat and design libraries.
dependencies {  
    compile 'com.android.support:appcompat-v7:X.X.X' // where X.X.X version
    compile 'com.android.support:design:X.X.X' // where X.X.X version
}
II. Make your activity extend android.support.v7.app.AppCompatActivity.
public class MainActivity extends AppCompatActivity {  
    ...
}
III. Declare your EditText inside any layout.xml file and wrap it with TextInputLayout.
<android.support.design.widget.TextInputLayout  
    android:id="@+id/inputLayout"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:errorEnabled="true">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/First_name" />

</android.support.design.widget.TextInputLayout>  
IV. To show/hide error use TextInputLayout#setError.
TextInputLayout inputLayout = (TextInputLayout) findViewById(R.id.inputLayout);  
inputLayout.setError("First name is required"); // show error  
inputLayout.setError(null); // hide error  
Declare app:errorEnabled="true" attribute inside TextInputLayout to reserve space for error label below EditText.

How to style?

Floating labels
I. Declare custom styles in your styles.xml file.
<!--Error label text style-->  
<style name="MyErrorText" parent="TextAppearance.AppCompat.Small">  
    <item name="android:textColor">@color/pink</item>
</style>

<!--Input field style-->  
<style name="MyEditText" parent="Theme.AppCompat.Light">  
    <item name="colorControlNormal">@color/indigo</item>
    <item name="colorControlActivated">@color/pink</item>
</style>  
II. Apply this styles to your TextInputLayout via app:errorTextAppearance attribute and to EditText via android:theme attribute.
<android.support.design.widget.TextInputLayout  
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:errorTextAppearance="@style/MyHintText"
    app:errorEnabled="true">

    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:hint="@string/Title"
        android:theme="@style/MyEditText" />

</android.support.design.widget.TextInputLayout>  

Issues

I. TextInputLayout comes with floating label and there is not way to disable it.
Reproduced in: all versions till v23.1.1
II. TextInputLayout label/hint is colored to red when setError method is triggered.
Reproduced in: only v23.1.1

Alerts : Material Design Tips

From Google material design documentation
Alerts are urgent interruptions, requiring acknowledgement, that inform the user about a situation.

How to add?

I. In your build.gradle add latest appcompat library.
dependencies {  
    compile 'com.android.support:appcompat-v7:X.X.X' // where X.X.X version
}
II. Make your activity extend android.support.v7.app.AppCompatActivity.
public class MainActivity extends AppCompatActivity {  
    ...
}
III. To create your dialog use android.support.v7.app.AlertDialog.Builder.
private void showLocationDialog() {  
    AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
    builder.setTitle(getString(R.string.dialog_title));
    builder.setMessage(getString(R.string.dialog_message));

    String positiveText = getString(android.R.string.ok);
    builder.setPositiveButton(positiveText,
            new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // positive button logic
        }
    });

    String negativeText = getString(android.R.string.cancel);
    builder.setNegativeButton(negativeText,
            new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            // negative button logic
        }
    });

    AlertDialog dialog = builder.create();
    // display dialog
    dialog.show();
}

How to style?

I. Declare custom drawable.xml for dialog background.
<?xml version="1.0" encoding="utf-8"?>  
<!-- From: support/v7/appcompat/res/drawable/abc_dialog_material_background_light.xml -->  
<inset xmlns:android="http://schemas.android.com/apk/res/android"  
    android:insetLeft="16dp"
    android:insetTop="16dp"
    android:insetRight="16dp"
    android:insetBottom="16dp">

    <shape android:shape="rectangle">
        <corners android:radius="2dp" />
        <solid android:color="@color/indigo" />
    </shape>

</inset>  
II. Declare custom styles in your styles.xml file.
<style name="MyDialogTheme" parent="Theme.AppCompat.Light.Dialog.Alert">  
    <!--buttons color-->
    <item name="colorAccent">@color/pink</item>
    <!--title and message color-->
    <item name="android:textColorPrimary">@android:color/white</item>
    <!--dialog background-->
    <item name="android:windowBackground">@drawable/background_dialog</item>
</style>  
III. Create your dialog and use style as parameter in AlertDialog.Builder.
AlertDialog.Builder builder =  
        new AlertDialog.Builder(this, R.style.MyDialogTheme);
...
AlertDialog dialog = builder.create();  
// display dialog
dialog.show();  
You can also style dialog in your activity theme via alertDialogTheme attribute.