Android Image Bulge

Source: Internet
Author: User

Transfer from http://blog.csdn.net/hupei/article/details/52064946

Overview

Today, there is a group of friends asked how the image of the Android images protruding effect, there have been similar requirements, the whole project prompt box is a background, the background has a convex half picture, so with Layer-list wrote a background to achieve.

Thought casually painted a bit more ugly, probably this looks like, from which should not be difficult to see, there are three parts, the top is transparent, the bottom is colored value, the hexagonal star is convex out of the picture. Then let's do it. Create a new resource file, with the Layer-list property, with three item, the first item set the height to 30DP, the second item set top to 30DP, just a vertical layout, the third item contains a bitmap tag, The effect is to maintain the original size of the picture. Code

Layer-list background

  1. <? XML version= "1.0" encoding="Utf-8"?>
  2. <layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  3. <item>
  4. <!--30DP Transparent --
  5. <shape>
  6. <size android:height="30DP" />
  7. <corners android:radius="10DP" />
  8. <solid android:color="@android: Color/transparent" />
  9. </shape>
  10. </Item>
  11. <!--offset 30dp-->
  12. <item android:top="30DP">
  13. <shape>
  14. <corners android:radius="10DP" />
  15. <solid android:color="@android: Color/white" />
  16. </shape>
  17. </Item>
  18. <!--use the bitmap label to keep the original size --
  19. <item>
  20. <bitmap
  21. android:gravity="Center_horizontal|top"
  22. android:src="@mipmap/ic_sync" />
  23. </Item>
  24. </layer-list>
Layout set root node background android:background= "@drawable/bg_money_dialog"
  1. <? XML version= "1.0" encoding="Utf-8"?><!--background bg_money_dialog-->
  2. <linearlayout xmlns:android="http://schemas.android.com/apk/res/android"
  3. android:layout_width="match_parent"
  4. android:layout_height="wrap_content"
  5. android:background="@drawable/bg_money_dialog"
  6. android:orientation="vertical">
  7. <EditText
  8. android:layout_width="match_parent"
  9. android:layout_height="wrap_content"
  10. android:gravity="Center_horizontal"
  11. android:hint="Please enter cash withdrawal amount" />
  12. <EditText
  13. android:layout_width="match_parent"
  14. android:layout_height="wrap_content"
  15. android:gravity="Center_horizontal"
  16. android:hint="Please enter your withdrawal password" />
  17. <Button
  18. android:layout_width="wrap_content"
  19. android:layout_height="wrap_content"
  20. android:layout_gravity="Center_horizontal"
  21. android:text="confirm" />
  22. </linearlayout>

Dialogfragment Code

  1. Public class Checkoutmoneydialog extends Dialogfragment {
  2. @Override
  3. Public Dialog Oncreatedialog (Bundle savedinstancestate) {
  4. Alertdialog.builder Builder = new Alertdialog.builder (Getactivity ());
  5. Layoutinflater inflater = getactivity (). Getlayoutinflater ();
  6. View view = Inflater.inflate (R.layout.fragment_checkout_money_dialog, null);
  7. Builder.setview (view);
  8. Dialog Dialog = Builder.create ();
  9. return dialog;
  10. }
  11. }
Run to see the effect
The effect is not good, may need to set EditText layout_margintop layout_margintop= "100DP" after the picture does not overlap on the EditText, can be top or no transparency effect, This reason is due to dialog background, the need for layout transparent, can dialog itself is also a background, we put dialog background transparent [Java]View PlainCopy
    1. Dialog Dialog = Builder.create ();
    2. window window = Dialog.getwindow ();
    3. Window.setbackgrounddrawableresource (Android. R.color.transparent);

Android Image Bulge

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.