Giter Site home page Giter Site logo

sdp's Introduction

issues Forks Stars Maven Central License

SDP - a scalable size unit

An android lib that provides a new size unit - sdp (scalable dp). This size unit scales with the screen size. It can help Android developers with supporting multiple screens.

for text views please refer to ssp which is based on the sp size unit for texts.

Attention

Use it carefully! for example, in most cases you still need to design a different layout for tablets.

Example

Here is a single layout built using sdp:

sdp example

And here is the same layout built using dp:

dp example

You can see that sdp scales with the screen size and the dp stays with the same size on all screen sizes.

Getting Started

To add sdp to your project (Using Android Studio and Gradle):

add implementation 'com.intuit.sdp:sdp-android:1.1.1' to your build.gradle dependencies block.

for example:

dependencies {
  implementation 'com.intuit.sdp:sdp-android:1.1.1'
}

See the sdp_example.xml to see how to use to the sdp size unit.

For easy mapping of designs to sdp units, one can create designs with 300 pixels screen width - in this case each pixel in the design corresponds to 1 sdp.

Note

The sdp size unit calculation includes some approximation due to some performance and usability constraints.

sdp's People

Contributors

despectra avatar elhanan-mishraky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdp's Issues

Android app crashes on opening a new activity Sign_Up

//Login activity
package com.example.vidhit.evoletandroid;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.example.vidhit.evoletandroid.R;

public class Login extends AppCompatActivity {

private EditText myemailEDT, myPasswordEDT;
private Button mySigninBT,mySignUpBt;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    try {
        getSupportActionBar().hide();
    }
    catch(Exception e)
    {
        System.out.println("exception ");
    }
    intialization();
}

private void intialization() {

    myemailEDT = (EditText) findViewById(R.id.activity_main_email_edt);
    myPasswordEDT = (EditText) findViewById(R.id.activity_main_pwd_edt);
    mySigninBT = (Button) findViewById(R.id.actvity_main_Signin_btn);
    mySignUpBt=(Button)findViewById(R.id.button);

    clickListener();



}

private void clickListener() {

/*

             Toast.makeText(getApplicationContext(), "Hello", Toast.LENGTH_SHORT).show();

           String aPwdSTR = myPasswordEDT.getText().toString();

            if (!aPwdSTR.equals(""))

            {

                Toast.makeText(getApplicationContext(), aPwdSTR, Toast.LENGTH_SHORT).show();

            }


            Intent aIntent = new Intent(getApplicationContext(), SecondActivity.class);
            Bundle aBundle = new Bundle();

            aBundle.putString("KEY", "VALUE");

            aIntent.putExtra("KEY", "Email");

            aIntent.putExtra("KEY1", "PWD");


            startActivity(aIntent);

*/

    mySigninBT.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            String user = myemailEDT.getText().toString();
            String pwd = myPasswordEDT.getText().toString();
            if (user.equals("")) {
                //System.out.println("Please enter username");
                Toast.makeText(Login.this, "Please enter username", Toast.LENGTH_SHORT).show();

            }
            else if (pwd.equals("")) {

                //System.out.println("Please enter password");
                Toast.makeText(Login.this, "Please enter password", Toast.LENGTH_SHORT).show();
            }
            else
            {
                Intent aIntent = new Intent(Login.this, SecondActivity.class);
                aIntent.putExtra("KEY1", user);
                aIntent.putExtra("KEY2", pwd);
                startActivity(aIntent);
            }

        }
    });
    mySignUpBt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            String user = myemailEDT.getText().toString();
            String pwd = myPasswordEDT.getText().toString();
            if (user.equals("")) {
                //System.out.println("Please enter username");
                Toast.makeText(Login.this, "Please enter username", Toast.LENGTH_SHORT).show();

            }
            else if (pwd.equals("")) {

                //System.out.println("Please enter password");
                Toast.makeText(Login.this, "Please enter password", Toast.LENGTH_SHORT).show();
            }
            else
            {
                Intent aIntents = new Intent(Login.this, Sign_Up.class);
                startActivity(aIntents);
            }

        }
    });


}

}

//Below is the Sign_Up activity

package com.example.vidhit.evoletandroid;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.TextView;
import android.widget.Toast;

public class Sign_Up extends AppCompatActivity {
private EditText myusr,mypwd,myemail,mycntno,mygender,myhobbies;
private TextView male,female;
private RadioButton m,f;
private CheckBox showpwd;
private Button next;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_sign_up);
    try {
        getSupportActionBar().hide();
    }
    catch(Exception e) {
        System.out.println("exception ");
    }
    intialization();
}

private void intialization() {

    myusr = (EditText) findViewById(R.id.Username);
    mypwd = (EditText) findViewById(R.id.Pwd);
    myemail = (EditText) findViewById(R.id.Email);
    mycntno = (EditText) findViewById(R.id.Cntno);
    mygender = (EditText) findViewById(R.id.Gender);
    myhobbies = (EditText) findViewById(R.id.Hobbies);
    male = (TextView) findViewById(R.id.Male);
    female = (TextView) findViewById(R.id.Female);
    m=(RadioButton) findViewById(R.id.rad_m);
    f=(RadioButton) findViewById(R.id.radioButton2);
    next=(Button)findViewById(R.id.Next);

    clickListener();
    onRadioButtonClicked();
    Intent aintent = getIntent();
    String value = aintent.getStringExtra("key");

}

private void onRadioButtonClicked() {
    m.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            boolean checked = ((RadioButton) view).isChecked();
            switch(view.getId())
            {
                case R.id.rad_m:
                    if(checked)
                        break;//male
                case R.id.radioButton2:
                        if(checked)
                            break;//female
            }
        }
    });
}

private void clickListener() {

    next.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String user1 = myusr.getText().toString();
            String pwd1 = mypwd.getText().toString();
            String email=myemail.getText().toString();
            String contact=mycntno.getText().toString();
            if (user1.equals("")) {
                //System.out.println("Please enter username");
                Toast.makeText(Sign_Up.this, "Please enter username", Toast.LENGTH_SHORT).show();

            }
            else if (pwd1.equals("")) {

                //System.out.println("Please enter password");
                Toast.makeText(Sign_Up.this, "Please enter password", Toast.LENGTH_SHORT).show();
            }
            else if (email.equals("")) {

                //System.out.println("Please enter password");
                Toast.makeText(Sign_Up.this, "Please enter password", Toast.LENGTH_SHORT).show();
            }
            else if (contact.equals("")) {

                //System.out.println("Please enter password");
                Toast.makeText(Sign_Up.this, "Please enter password", Toast.LENGTH_SHORT).show();
            }
            else
            {
                Intent aIntent = new Intent(Sign_Up.this, successregister.class);
                aIntent.putExtra("KEY1", user1);
                aIntent.putExtra("KEY2", pwd1);
                startActivity(aIntent);
        }
    }

});
}

}

Logcat:
02-08 17:40:57.682 5226-5226/? I/zygote: Not late-enabling -Xcheck:jni (already on)
02-08 17:40:57.729 5226-5226/? W/zygote: Unexpected CPU variant for X86 using defaults: x86
02-08 17:40:57.978 5226-5226/com.example.vidhit.evoletandroid I/InstantRun: starting instant run server: is main process
02-08 17:40:58.202 5226-5258/com.example.vidhit.evoletandroid D/OpenGLRenderer: HWUI GL Pipeline
02-08 17:40:58.336 5226-5258/com.example.vidhit.evoletandroid I/zygote: android::hardware::configstore::V1_0::ISurfaceFlingerConfigs::hasWideColorDisplay retrieved: 0
02-08 17:40:58.336 5226-5258/com.example.vidhit.evoletandroid I/OpenGLRenderer: Initialized EGL, version 1.4
02-08 17:40:58.336 5226-5258/com.example.vidhit.evoletandroid D/OpenGLRenderer: Swap behavior 1
02-08 17:40:58.339 5226-5258/com.example.vidhit.evoletandroid D/EGL_emulation: eglCreateContext: 0xa46840c0: maj 2 min 0 rcv 2
02-08 17:40:58.349 5226-5258/com.example.vidhit.evoletandroid D/EGL_emulation: eglMakeCurrent: 0xa46840c0: ver 2 0 (tinfo 0xa46832d0)
02-08 17:40:58.386 5226-5258/com.example.vidhit.evoletandroid D/EGL_emulation: eglMakeCurrent: 0xa46840c0: ver 2 0 (tinfo 0xa46832d0)
02-08 17:41:01.389 5226-5258/com.example.vidhit.evoletandroid D/EGL_emulation: eglMakeCurrent: 0xa46840c0: ver 2 0 (tinfo 0xa46832d0)
02-08 17:41:01.875 5226-5226/com.example.vidhit.evoletandroid V/View: dispatchProvideAutofillStructure(): not laid out, ignoring 2 children of 1073741832
02-08 17:41:01.877 5226-5226/com.example.vidhit.evoletandroid I/AssistStructure: Flattened final assist data: 2976 bytes, containing 1 windows, 10 views
02-08 17:41:06.665 5226-5241/com.example.vidhit.evoletandroid I/zygote: Do partial code cache collection, code=29KB, data=28KB
02-08 17:41:06.665 5226-5241/com.example.vidhit.evoletandroid I/zygote: After code cache collection, code=29KB, data=28KB
02-08 17:41:06.665 5226-5241/com.example.vidhit.evoletandroid I/zygote: Increasing code cache capacity to 128KB
02-08 17:41:08.646 5226-5226/com.example.vidhit.evoletandroid D/AndroidRuntime: Shutting down VM
02-08 17:41:08.649 5226-5226/com.example.vidhit.evoletandroid E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.vidhit.evoletandroid, PID: 5226
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.vidhit.evoletandroid/com.example.vidhit.evoletandroid.Sign_Up}: android.view.InflateException: Binary XML file line #0: Can't convert value at index 3 to dimension: type=0x12
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.view.InflateException: Binary XML file line #0: Can't convert value at index 3 to dimension: type=0x12
Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 3 to dimension: type=0x12
at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:730)
at android.view.ViewGroup$MarginLayoutParams.(ViewGroup.java:7767)
at android.widget.RelativeLayout$LayoutParams.(RelativeLayout.java:1269)
at android.widget.RelativeLayout.generateLayoutParams(RelativeLayout.java:1090)
at android.widget.RelativeLayout.generateLayoutParams(RelativeLayout.java:1088)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:865)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.vidhit.evoletandroid.Sign_Up.onCreate(Sign_Up.java:25)
at android.app.Activity.performCreate(Activity.java:6999)
at android.app.Activity.performCreate(Activity.java:6990)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2731)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
02-08 17:41:08.819 5226-5241/com.example.vidhit.evoletandroid I/zygote: Do partial code cache collection, code=45KB, data=50KB
02-08 17:41:08.820 5226-5241/com.example.vidhit.evoletandroid I/zygote: After code cache collection, code=45KB, data=50KB
02-08 17:41:08.820 5226-5241/com.example.vidhit.evoletandroid I/zygote: Increasing code cache capacity to 256KB
02-08 17:41:08.828 5226-5241/com.example.vidhit.evoletandroid I/zygote: JIT allocated 71KB for compiled code of void android.widget.TextView.(android.content.Context, android.util.AttributeSet, int, int)
02-08 17:41:08.828 5226-5241/com.example.vidhit.evoletandroid I/zygote: Compiler allocated 4MB to compile void android.widget.TextView.(android.content.Context, android.util.AttributeSet, int, int)

Manifest file:

<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/AppTheme">
    <activity android:name=".Splashscreen">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".Login" />
    <activity android:name=".SecondActivity" />
    <activity android:name=".Sign_Up" />
    <activity android:name=".successregister"></activity>
</application>

Question:
When i enter my email and password and click on the signup button my app crashes .Sign in button is working perfectly fine only the sign up button is the main problem.Can anyone help me in resolving this error?.

Working or not

when ever i try to add dependencies its show error
Error:Unable to resolve dependency for ':app@debug/compileClasspath': Could not resolve com.intuit.sdp:sdp-android:1.0.5. <a href="openFile:C:/Users/xxx/AndroidStudioProjects/xxx/app/build.gradle">Open File</a><br><a href="Unable to resolve dependency for &#39;:app@debug/compileClasspath&#39;: Could not resolve com.intuit.sdp:sdp-android:1.0.5.">Show Details</a> any solution for this

Thanks

Thanks for your efforts !!

Fractional values of sdp

It would be nice if there were fractional sdp values, e.g. @dimen/_3pt5sdp or maybe @dimen/_3_5sdp or something like that, because sometimes I want to position my views on layout more precisely

InflateException coming for few android 7.0 devices

InflateException is coming for few android device having version 7.0 on eample code
android:layout_marginTop="@dimen/_45ssp".

Stacktrace:

Caused by: android.view.InflateException: Binary XML file line #33: Binary XML file line #33: Error inflating class TextView
Caused by: android.view.InflateException: Binary XML file line #33: Error inflating class TextView
Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 2 to dimension: type=0x1
at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:720)
at android.widget.TextView.(TextView.java:1088)
at android.widget.TextView.(TextView.java:704)
at android.support.v7.widget.bm.(Unknown Source)
at android.support.v7.widget.bm.(Unknown Source)

Need Bit Clarification

i could not figure out ,whats'the logic behind this.But it is working fine .Based on What you are taking these sdp values ?is it a Px based or Dp Based ?
For example,if i want my app to support from 240 width screen to 720 width screen,what should i do ?should i ask my Designer to give the UI(.psd) in 240px width ?

Getting problem in Samsung note 8

I have been using this library but now as new device with slim dimensions and high resolutions (1440 x 2960 pixels) like samsung galaxy s8 , note 8 and s9 are not supporting this lib. We are facing problem in textview size. Can you please help me to fix this issue.

Awaiting for your reply.

need your help

hi,
i'm using awesome sdp library in my apps, but i need your help!
i found no way to contact you, that's why i posted here.
i want to convert dp to pixel or pixel to dp programmatically but the result is not good!
i tried different ways but none of these codes results is not like sdp library.
float px = dp * (metrics.densityDpi / metrics.DENSITY_DEFAULT);
or
float px = dp * getResources().getDisplayMetrics().density; + 0.5f;
....
can you help me?
many thanks

License question

Hi,
really like the library... Android should have something like this official!
The MIT license says attribution is required. Is this also for binary distribution or only source?
For example if I upload my app in a app store, do I need to attribute?
Because my app does not have a good place for that like about or something.
Also is this project still in development?
Thanks

Why 300 as base width?

As per android buckets for mdpi (360 width) 1dp = 1px. So why are you using 300 as a base and why not 360??. If you use 360 as base then we can directly assign values provided in px to sdp.

AAPT2 when linking resources gives error

AGPBI: {"kind":"error","text":"error: resource android:attr/foregroundInsidePadding is private.","sources":[{"file":"C:\Users\MyPC\.gradle\caches\transforms-1\files-1.1\sdp-android-1.0.5.aar\6ace9734fe0036a609208f5ef2a38545\res\values\values.xml","position":{"startLine":2,"startColumn":4,"startOffset":55,"endColumn":42,"endOffset":93}}],"original":"","tool":"AAPT"}

Failed to process resources.

Width doesn't work on orientation change?

First of all, I would like to thank you for this wonderful library.

I have below layout and am setting min_width and max_width for textviews. If I change the screen orientation, it will not change the width of textviews. Is this expected behavior or is there any issue?

<RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:paddingTop="2sp">
           <TextView
                android:id="@+id/txtCustName"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:maxWidth="@dimen/_60sdp"
                android:minWidth="@dimen/_60sdp"
                android:ellipsize="end"
                android:maxLines="1"
                android:padding="2sp"
                android:singleLine="true"
                android:textColor="#000000"
                android:textSize="@dimen/_13sdp"
                android:textStyle="bold"
                tools:ignore="Deprecated" />

            <RelativeLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:id="@+id/relMiddleContainer"
                android:layout_toEndOf="@+id/txtCustName">

                <TextView
                    android:id="@+id/txtCustCode"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:ellipsize="end"
                    android:minWidth="@dimen/_20sdp"
                    android:maxWidth="@dimen/_20sdp"
                    android:maxLines="1"
                    android:padding="2sp"
                    android:singleLine="true"
                    android:textColor="#8b8b8b"
                    android:textSize="@dimen/_12sdp"
                    tools:ignore="Deprecated" />
          </RelativeLayout>
</RelativeLayout>

Failed to resolve sdp-android

In Android Studio 3.1 , the library is not compiling and showing failed to resolve sdp-android
please give me the solution

Robolectric

When I'm trying to use robolectric framework with layout covered by sdp, I'm getting this error:

android.view.InflateException: XML file build\intermediates\res\merged\debug\layout\activity_main.xml line #-1 (sorry, not yet implemented): XML file build\intermediates\res\merged\debug\layout\activity_main.xml line #-1 (sorry, not yet implemented): Error inflating class Button

at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:280)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.gmail.zubrapps.calculatedistance.MainActivity.onCreate(MainActivity.java:26)
at android.app.Activity.performCreate(Activity.java:6237)
at org.robolectric.util.ReflectionHelpers.callInstanceMethod(ReflectionHelpers.java:195)
at org.robolectric.util.ActivityController$1.run(ActivityController.java:126)
at org.robolectric.shadows.ShadowLooper.runPaused(ShadowLooper.java:340)
at org.robolectric.shadows.CoreShadowsAdapter$2.runPaused(CoreShadowsAdapter.java:40)
at org.robolectric.util.ActivityController.create(ActivityController.java:123)
at org.robolectric.util.ActivityController.create(ActivityController.java:133)
at org.robolectric.util.ActivityController.setup(ActivityController.java:227)
at org.robolectric.Robolectric.setupActivity(Robolectric.java:96)
at com.gmail.zubrapps.calculatedistance.MainActivityTest.validateTextViewContent(MainActivityTest.java:17)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:467)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:250)
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:176)
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:49)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:142)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

Caused by: android.view.InflateException: XML file build\intermediates\res\merged\debug\layout\activity_main.xml line #-1 (sorry, not yet implemented): Error inflating class Button
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:782)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
... 35 more
Caused by: java.lang.UnsupportedOperationException: Can't convert to dimension: type=0x1
at android.content.res.TypedArray.getDimensionPixelSize(TypedArray.java:666)
at android.widget.TextView.constructor(TextView.java:1055)
at android.widget.TextView.(TextView.java)
at android.widget.Button.(Button.java)
at android.support.v7.widget.AppCompatButton.(AppCompatButton.java)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:109)
at android.support.v7.app.AppCompatDelegateImplV7.createView(AppCompatDelegateImplV7.java:1008)
at android.support.v7.app.AppCompatDelegateImplV7.onCreateView(AppCompatDelegateImplV7.java:1067)
at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView(LayoutInflaterCompatHC.java:44)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:746)
... 39 more

I wonder, if its because robolectric cannot know the size of device, so sdp cannot be converted to the proper dp. My question is: Is there any possibility to overcome this issue?

Larger DPs

I have been trying to use 465.40dp within the sw780dp/values xml but when use that its actually making it 179dp not 465.40 dp. Do I need to call that another way then just changing my 465dp to "@dimen/_179sdp" ?

Support for SP values

I really liked this library as it saves my lot of time. Only thing missing apart from fractional value is SP values for text.

Need Information

is sdp library support different drawable based on screen configuration?

the size is not same with dp

the size is not same at all with the dp that provide by Android, for example 100 sdp is not same size with 100 dp, please help me with this issue.

How to calculate dp ?

Hello, I have used your library and just awesome. but i am confuse in resolution 1600 * 2560 resolution where Height : 1600 and width :2560, So please give me your formula for add dimensions in new resolution.

duplicate value for resource 'attr/font' past

Getting duplicate value for resource 'attr/font' past couple of hours. Need your help.

Message{kind=ERROR, text=error: duplicate value for resource 'attr/font' with config ''., sources=[C:\Users\###\.gradle\caches\transforms-1\files-1.1\sdp-android-1.0.5.aar\d513ef727a30bd4a753b67a99c92758b\res\values\values.xml:3:5-43], original message=, tool name=Optional.of(AAPT)}

Problem coming when I add facebook-android-sdk.

build.gradle

implementation 'com.intuit.sdp:sdp-android:1.0.5' 
implementation 'com.facebook.android:facebook-android-sdk:4.33.0'

I already tried with your old versions. Same issue. Any help would be greatly appreciated.

Provide support for the latest API level

Hello,
We are currently using your library in one of our application. Actually we need a favour from your side. According to the Google Play Policy, all apps have to provide support for at least API level 26 which is satisfied in your case. We are targeting API level 28. So can you please provide us support for API level 28 in your current repository?

Not working properly

Hi,

I have an issue making this work. I used sdp but still see different layouts and font sizes not scaling up properly.

capture

Here's my layout code

`

<android.support.v7.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:card_view="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardUseCompatPadding="true"
card_view:cardCornerRadius="@dimen/_8sdp"
card_view:cardBackgroundColor="@android:color/white">

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <ImageView
        android:id="@+id/item_tourist_spot_card_image"
        android:layout_width="match_parent"
        android:layout_height="@dimen/_200sdp"
        android:layout_alignParentStart="true"
        android:layout_alignParentTop="true"
        android:scaleType="centerCrop" />

    <TextView
        android:id="@+id/item_tourist_spot_card_name"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="0dp"
        android:paddingLeft="@dimen/_10sdp"
        android:paddingRight="@dimen/_10sdp"
        android:paddingTop="@dimen/_10sdp"
        android:textColor="@android:color/black"
        android:textSize="@dimen/_15sdp" />

    <TextView
        android:id="@+id/item_tourist_spot_card_city"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingBottom="0dp"
        android:paddingLeft="@dimen/_10sdp"
        android:paddingRight="@dimen/_10sdp"
        android:paddingTop="@dimen/_5sdp"
        android:textColor="@android:color/black"
        android:textSize="@dimen/_13sdp" />

</LinearLayout>

</android.support.v7.widget.CardView>`

Any chance we can put this on Gradle repository?

It's a hassle having to download and setup this project.

It would be nice if possible to just include it as Gradle dependancy in one line and Gradle will handle with downloading and resolving automatically.

Not working fine

Try with google nexus 4 - 4.1.1 API 16. 768*1280 320dpi (Genymotion emulator). If I set proper layout sdp that fits in this configuration, then It looks wired and too small in Samsung Galaxy Tab 4, 8".

README with more information

I'm confused because I dont understand as work this tool, with a layout I can support all screens?

Can add an example project with this library?

Programmatic way to set sizes in sdp

Hello! Thanks for the work you've done. Sometimes the sizes have to be set programmatically in pixels, meaning that I couldn't use the advantage of your library. Could there be some method that could convert sdp to px?

Add Material Design Specs

It would be nice if material design dimensions are provided by default. As using sdp as material design differs the dimensions from original spec.

Irregularity in sizing of views on Nexus 6 in Android.

I have a layout containing just an image. I have set its dimensions using SDP. When I previewed the layout on Nexus 6 (6 inch, xxxhdpi) in the layout preview, the image was in bounds of the screen. But when i used Google Pixel (5 inch, xxhdpi) to preview, the image became out of bounds of the screen.
What I expected was the image would be in same proportion irrespective of screen.

Dimensions of ImageView :
layout_width = @dimen/_300sdp (which became 390dp for Nexus 6 and 360dp for Google Pixel)
layout_height = @dimen/_450sdp (which became 585dp for Nexus 6 and 540dp for Google Pixel)

I have previewed the same layout with other mid size devices such as Nexus 5, Nexus 4, Galaxy Nexus and the ImageView in all these devices goes out of bounds. But in larger devices such as Nexus 5X, Pixel XL and Nexus 6P, the ImageView stays inside the screen.

pixel

nexus6

Reduce the "minSdkVersion" to 11 if possible (currently at 13)

I have included the library in my project which has "minSdkVersion" value of 11. However, this library has the value set to 11 and Android Studio complains with an error while building:

Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 11 cannot be smaller than version 13 declared in library P:\AndroidStudioProjects\Bla\app\build\intermediates\exploded-aar\com.intuit.sdp\sdp-android\1.0.2\AndroidManifest.xml
    Suggestion: use tools:overrideLibrary="com.intuit.sdp" to force usage

Is version 13 really necessary for the library? I don't want to reduce my potential audience just because of "sdp", if possible.

Not able to select any edit text except username and contact editext field

When i am trying to click on the password editext field then there is no response and the cursor moves on to the contact no edit text field.The only way through which one can access all the edit text fields is through the TAB key.Similarly, i am not able to type anything in the email edit text field as it does not respond to the touch.Can anyone tell me how to make the touch work perfectly?.I am attaching the image of the activity running on the emulator along with the code
android error

//successregister activity file

<TextView
    android:id="@+id/textView3"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentTop="true"
    android:layout_centerHorizontal="true"
    android:paddingTop="40dp"
    android:textSize="15sp"
    android:textColor="@color/black"
    android:textAllCaps="true"
    android:text="You are successfully registered" />

<TextView
    android:id="@+id/usr"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/textView3"
    android:paddingTop="40dp"
    android:text="Username :"
    android:textColor="@color/black"
    android:paddingLeft="10dp"/>

<TextView
    android:id="@+id/pass"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/usr"
    android:paddingTop="40dp"
    android:text="Password :"
    android:textColor="@color/black"
    android:paddingLeft="10dp"/>

<TextView
    android:id="@+id/em"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/pass"
    android:paddingTop="40dp"
    android:text="Email :"
    android:textColor="@color/black"
    android:paddingLeft="10dp"/>

<TextView
    android:id="@+id/contact"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/em"
    android:paddingTop="40dp"
    android:text="Contact No :"
    android:textColor="@color/black"
    android:paddingLeft="10dp"/>

<EditText
    android:id="@+id/usered"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:paddingTop="83dp" />

<EditText
    android:id="@+id/passedit"
    android:layout_width="200dp"
    android:focusable="true"
    android:focusableInTouchMode="true"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    android:layout_alignParentTop="true"
    android:paddingTop="141dp" />

<EditText
    android:id="@+id/emaedit"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:layout_above="@+id/contact"
    android:layout_alignParentEnd="true"
    android:layout_alignParentRight="true"
    android:paddingTop="201dp"
    android:singleLine="true" />

<EditText
    android:id="@+id/contactsedit"
    android:layout_width="200dp"
    android:layout_height="wrap_content"
    android:layout_alignParentRight="true"
    android:paddingTop="260dp" />

//Java file

package com.example.vidhit.evoletandroid;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.EditText;
import android.widget.TextView;

public class successregister extends AppCompatActivity {

private EditText usern,passwd,emails,cnt_no;
private TextView muse,mpassword,mem,mcnt_no;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_successregister);
   initialization();
}

private void initialization() {

    usern=(EditText)findViewById(R.id.usered);
    passwd=(EditText)findViewById(R.id.passedit);
    emails=(EditText)findViewById(R.id.emaedit);
    cnt_no=(EditText)findViewById(R.id.contactsedit);
    muse=(TextView)findViewById(R.id.usr);
    mpassword=(TextView)findViewById(R.id.pass);
    mem=(TextView)findViewById(R.id.em);
    mcnt_no=(TextView)findViewById(R.id.contact);


    Intent intent=getIntent();
    //String name=intent.getStringExtra("myname");
    Bundle bundle=getIntent().getExtras();
    Bundle bundle1=getIntent().getExtras();
    Bundle bundle2=getIntent().getExtras();
    Bundle bundle3=getIntent().getExtras();
    String name=bundle.getString("myname");
    String pass=bundle1.getString("mypassword");
    String em=bundle2.getString("myemail");
    String contact=bundle3.getString("mycontact");
    usern.setText(name);
    passwd.setText(pass);
    emails.setText(em);
    cnt_no.setText(contact);



}

}

using for sdk 8

how i could use this library for android 2.2 or min sdk 8?! would u plz help me, this library really helped me but i need it for minsdk 8

not working on width?

I can change layout_height of ImageView. And immediately it changes in preview. But cant change layout_width. Why cant edit it?

   <ScrollView
        android:id="@+id/scrollView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:fadingEdge="none"
        android:fillViewport="true"
        android:layout_marginTop="@dimen/_60sdp"
        android:layout_marginBottom="@dimen/_60sdp"

        >

        <RelativeLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:layout_gravity="top|center"
            android:gravity="center"
            >



            <TableLayout
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                >


                <TableRow
                    android:gravity="center"
                    android:layout_margin="@dimen/_10sdp">

                <ImageButton

                    android:background="@mipmap/menuicons2"
                    android:layout_margin="@dimen/_10sdp"
                  android:layout_width="@dimen/_70sdp"
                    android:layout_height="@dimen/_10sdp"
                    android:id="@+id/imageButtonS"
                    android:onClick="buttonOnclick" />

                <ImageButton

                    android:background="@mipmap/menuicons1"
                    android:layout_margin="@dimen/_10sdp"

                    android:layout_width="@dimen/_70sdp"
                    android:layout_height="@dimen/_10sdp"

                    android:id="@+id/imageButtonC"
                    android:onClick="buttonOnclick"

                    />

                <ImageButton

                    android:background="@mipmap/menuicons12"
                    android:layout_margin="@dimen/_10sdp"

                    android:layout_width="@dimen/_70sdp"
                    android:layout_height="@dimen/_10sdp"

                    android:id="@+id/imageButtonY"
                    android:onClick="buttonOnclick"

                    />
                </TableRow>

Android Version

Could you please tell me if android version needs to be changed on implementing library?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.