2014-07-26 8 views
5

मेरे ऐप में मैं अपने आकार के लगभग 120% तक विस्तारित आइकन को एनिमेट करना चाहता हूं। समस्या यह है कि जब मैं ऐसा करता हूं तो ImageView की सामग्री काट दिया जाता है। क्या ऐसा करने के लिए वैसे भी है ताकि ऐसा न हो?ImageView स्केल अप एनीमेशन कट ऑफ छवि

enter image description here

एनीमेशन के बुला:

Animation sgAnimation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.highlight); 
charm.startAnimation(sgAnimation); 

एनीमेशन ही:

<?xml version="1.0" encoding="utf-8"?> 
<set xmlns:android="http://schemas.android.com/apk/res/android" 
android:fillAfter="true" 
android:fillBefore="true" 
android:interpolator="@android:anim/accelerate_interpolator" 
android:shareInterpolator="true" > 

<scale 
    android:duration="100" 
    android:pivotX="50%" 
    android:pivotY="50%" 
    android:fromXScale="1.0" 
    android:fromYScale="1.0" 
    android:toXScale="1.5" 
    android:toYScale="1.5" /> 
</set> 

और imageView से संबंधित लेआउट अनुभाग:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/over_container" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    >   
<RelativeLayout 
    android:id="@+id/charms_bar" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_centerHorizontal="true" 
    android:layout_marginBottom="15dp" 
    android:layout_marginLeft="15dp" 
    android:layout_marginRight="15dp" > 

    <ImageView 
     android:id="@+id/charm_phone" 
     android:layout_width="24dp" 
     android:layout_height="24dp" 
     android:layout_alignParentLeft="true" 
     android:layout_centerVertical="true" 
     android:alpha=".75" 
     android:contentDescription="@string/account_image_description" 
     android:src="@drawable/ic_phone_white_24dp" /> 

    <ImageView 
     android:id="@+id/charm_lock" 
     android:layout_width="24dp" 
     android:layout_height="24dp" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:contentDescription="@string/account_image_description" 
     android:src="@drawable/ic_qs_lock_screen_off" /> 

    <ImageView 
     android:id="@+id/charm_camera" 
     android:layout_width="24dp" 
     android:layout_height="24dp" 
     android:layout_alignParentRight="true" 
     android:layout_centerVertical="true" 
     android:alpha=".75" 
     android:contentDescription="@string/account_image_description" 
     android:src="@drawable/ic_camera_white_24dp" /> 

नोट: मैं पहले से ही wrap_content साथ 24dp की जगह की कोशिश की है, लेकिन वह

उत्तर

1

तो मैंने छविदृश्य में पैडिंग जोड़ने और अतिरिक्त पैडिंग द्वारा छविदृश्य के आकार को बढ़ाने का अंत किया। इस तरह जब यह एनिमेटेड था, यह पैडिंग स्पेस में एनिमेटेड था और फसल नहीं हुई थी।

13

काम नहीं किया मैं

android:clipChildren="false" 
android:clipToPadding="false" 

का उपयोग कर अपने imageView कंटेनर में और अपने imageView में कोशिश करेंगे

+0

कोई पासा दुर्भाग्य से अभी भी क्लिप – BionicSheep

+0

आप अपने लेआउट पोस्ट कर सकते हैं करें:

एक छवि को ध्यान में रखते? – AlexBalo

+0

ने कंटेनर जोड़ा और खुद को मूल पोस्ट – BionicSheep

0

स्केलिंग एनीमेशन के अनुसार आप ImageView की पैरेंट लेआउट ऊंचाई देकर अपेक्षित परिणाम प्राप्त कर सकते थे।

अपने मामले में आप एक छवि दृश्य को एनिमेट करने का प्रयास कर रहे हैं जो चौड़ाई और ऊंचाई में 24 डीपी है। इसलिए आपको ImageView के ठीक से एनिमेट करने के लिए 36 डीपी कमरा की आवश्यकता होगी। चूंकि आपने लेआउट चौड़ाई को match_parent के रूप में दिया है, इसलिए आपकी छवि बाएं और दाएं किनारे से नहीं आई है, लेकिन ऊंचाई के लिए सामग्री लपेटना काम नहीं करेगा।

<RelativeLayout 
    android:id="@+id/relative_layout" 
    android:layout_width="match_parent" 
    android:layout_height="36dp"> 

    <ImageView 
     android:id="@+id/image_view" 
     android:layout_width="24dp" 
     android:layout_height="24dp" 
     android:layout_margin="6dp" 
     android:layout_alignParentLeft="true" 
     android:src="@drawable/src_image"/> 

<RelativeLayout/> 
संबंधित मुद्दे