unipiazza/unipiazza-android-twostepslogin

Increase padding/margin without revealing activity background

Opened this issue · 10 comments

Hi,

Great library! I was wondering if there is a way to increase the loginview margin/padding without displaying the activity background?

If I apply margin or padding to the login_view in xml, the different color activity background is shown around the login view.

Basically I would like the login_view to be full screen but the controls must be padded from the screen as currently it is sitting right on the edge of the screen.

Thanks

I do not know if I correctly understand what do you mean, but theorically setting more padding to login_video in xml should work. Are you really sure that it doesn't?

Using margin instead, could result in different color, but you can always set the color of activity as the background color of MaterialTwoStepsLogin...am i wrong?

Otherwise, for complete customization, my advice is to fork the project and change what do you want, it is not so complicated.

Hi monossido,

I will try setting the padding to login_video and see if that works.

Essentially what is happening is the following:

I have an activity with a white background.
I add your login control to the xml (first step has purple background and second step has white background).

<com.unipiazza.material2stepslogin.view.MaterialTwoStepsLogin
android:id="@+id/login_view"
android:layout_width="match_parent"
android:layout_height="wrap_content" />

The button in your control is spanned across the screen from edge to edge as there is no padding on the next button.

I add padding to your control in the xml file like below:

<com.unipiazza.material2stepslogin.view.MaterialTwoStepsLogin
android:id="@+id/login_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding_left="15dp"
android:padding_right="15dp" />

The problem now is that there is a white edge around the purple background of the first step. This is due to the background of the activity that is now visible. I can change the background of the activity to purple which will solve the problem on the first step but then a purple edge is visible on the second step as the activity background color is purple and the background of the second step of your control is white.

I want to be able to keep your control to fill the parent but not have the button right on the edges of the screen. The textedits are also pretty close to the screens edge which I want to change. I basically want it to look like the preview in the github readme file.

Will setting the padding on login_video in the xml work? or do you mean login_view? Because I am adding the padding to login_view. Using margin results in the same problem.

Thanks
J

You are right, also with padding it doesn't work, becouse of child view background.

As a workaround you can use this in onResume of your activity

int px = ...
FrameLayout fragmentView = (FrameLayout) login_view.findViewById(R.id.fragmentView);
fragmentView.getChildAt(0).setPadding(px, px, px, px);

I will keep open this in order to develop a better solution

Thank you Lorenzo,

I will try the solution and revert back.

Thanks
J

Hi Lorenzo, I tried the workaround which you supplied and it works grea... for the first step where email is entered. How would I go about doing the same for the second step where the password is entered?

Thanks for your help.

It's a little more tricky becouse the second fragment must be completly active when you call getChildAt()
But you can try to do this

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                FrameLayout fragmentView = (FrameLayout) login_view.findViewById(R.id.fragmentView);
                fragmentView.getChildAt(0).setPadding(px, px, px, px);
            }
        }, 200);

just after you call setInfosAfterNext

Hi Lorenzo,

I think I will have to download your project and include it as a library in my project due to the fact that I will need to change the fonts on the login screen, sort out the padding and furthermore I want to wire up the softkeys on the keyboard such as "Next" and "Done" to perform the relevant actions. I just wanted to check something with you as I am fairly new to android development. I came across this SO solution about how to import the library:

http://stackoverflow.com/questions/20467279/importing-github-projects-as-library-to-existing-project

They explain that you need to download the library from github. in the case of the question you have to copy the "Library" folder into the libs folder of your android studio. I assume in the case of your library it will be the "materialtwostepslogin" folder correct? and then I can customize the plugin within the libs folder and include it in my projects gradle as outlined in the question yes?

Thanks
J

Yes, I think it's better to import the code and editing it.
If you have usefull solutions you can try to make a pull request to this project in order to collaborate.

The stackoverflow answer that you have linked it's what you need.

Hi Lorenzo,

Im having major issues with trying to import the code into my existing project in android studio. I think it is most likely due to my lack of understanding. Do you perhaps have a simple explanation as to how I can import the code and use it as I am currently using it in my project?

I managed to get it to import but where I use it in my login activity, android studio says it cannot resolve the symbol. MaterialTwoStepsLogin. This is probably due to the import statement no longer being relative (import com.unipiazza.....) This should probably be changed to use the local copy but I have two libs folders. One in my project root and one in my app root... OI the confusion.

Thanks
J

Hi Lorenzo,

I got it going. In all honesty I am not sure what I did but I imported the project into android studio and started mucking about in the gradle files, excluded a bunch of github stuff and sure enough eventually it compiled and I can now edit the code to fit my requirements.

Thanks for all your input thusfar. it is very much appreciated.

Thanks
J