मुझे यकीन नहीं है कि यह Animations
के साथ किया जा सकता है। एंड्रॉइड व्यू में एनीमेशन समाप्त होने से पहले सभी जगह लेती है, इसलिए आप देखेंगे कि अन्य संपादन टेक्स्ट गायब हो जाते हैं और धीरे-धीरे बढ़ते हुए चुने जाते हैं। यहाँ किसी न किसी उदाहरण कैसे standart एनिमेशन के बिना यह करने के लिए है, लेकिन है अलग थ्रेड में बदल रहा है वजन:
लेआउट:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
OnFocusChangeListener focusListener = new OnFocusChangeListener() {
@Override
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
LinearLayout parent = (LinearLayout) v.getParent();
EditText forDecresing = null;
for (int i = 0; i < parent.getChildCount(); i++) {
if (parent.getChildAt(i) != v) {
forDecresing = (EditText) parent.getChildAt(i);
break;
}
}
LinearLayout pp = (LinearLayout) parent.getParent();
LinearLayout layoutForDecreasing = null;
for (int i = 0; i < pp.getChildCount(); i++) {
if (pp.getChildAt(i) != parent && pp.getChildAt(i) instanceof LinearLayout) {
layoutForDecreasing = (LinearLayout) pp.getChildAt(i);
break;
}
}
startAnimation((EditText) v, forDecresing, layoutForDecreasing, parent);
} else {
}
}
};
((EditText) findViewById(R.id.et00)).setOnFocusChangeListener(focusListener);
((EditText) findViewById(R.id.et01)).setOnFocusChangeListener(focusListener);
((EditText) findViewById(R.id.et11)).setOnFocusChangeListener(focusListener);
((EditText) findViewById(R.id.et10)).setOnFocusChangeListener(focusListener);
}
public void onBackPressed() {
setWeight(findViewById(R.id.et00), 1);
setWeight(findViewById(R.id.et01), 1);
setWeight(findViewById(R.id.et11), 1);
setWeight(findViewById(R.id.et10), 1);
setWeight(findViewById(R.id.ll1), 1);
setWeight(findViewById(R.id.ll0), 1);
}
Thread animationThread;
private void startAnimation(final EditText forIncreasing, final EditText forDecresing, final LinearLayout layoutForDecreasing,
final LinearLayout layoutForIncreasing) {
if (animationThread != null)
animationThread.interrupt();
animationThread = new Thread(new Runnable() {
@Override
public void run() {
int iterations = 0;
int maxIterations = 30;
setWeight(forIncreasing, maxIterations - 1);
setWeight(layoutForIncreasing, maxIterations - 1);
setWeight(forDecresing, maxIterations - 1);
setWeight(layoutForDecreasing, maxIterations - 1);
while (iterations < maxIterations) {
iterations++;
setWeight(forIncreasing, maxIterations - 1 + iterations);
setWeight(layoutForIncreasing, maxIterations - 1 + iterations);
setWeight(forDecresing, maxIterations - 1 - iterations);
setWeight(layoutForDecreasing, maxIterations - 1 - iterations);
try {
Thread.sleep(10);
} catch (InterruptedException e) {
return;
}
}
animationThread = null;
}
});
animationThread.start();
}
private void setWeight(final View view, final float weight) {
runOnUiThread(new Runnable() {
@Override
public void run() {
LayoutParams params = (LayoutParams) view.getLayoutParams();
params.weight = weight;
view.setLayoutParams(params);
}
});
}
मुझे क्या करना:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/ll0"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<EditText
android:id="@+id/et00"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="top|left"
android:text="00" />
<EditText
android:id="@+id/et01"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="top|left"
android:text="01" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll1"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="horizontal" >
<EditText
android:id="@+id/et10"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="top|left"
android:text="10" />
<EditText
android:id="@+id/et11"
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:gravity="top|left"
android:text="11" />
</LinearLayout>
</LinearLayout>
और कोड में बदलने के फोकस पर कार्रवाई जोड़ने यह नहीं पता कि यह आपके लिए संभव है, लेकिन इस उदाहरण में आप कुछ और आंदोलनों को काफी आसान जोड़ सकते हैं।
मैं ऐसा नहीं अनुशंसा करते हैं यह उत्पादन का उपयोग करता है, तो केवल आप कुछ अन्य विकल्प हैं।
हां, तो आप edittext लेआउट के भरण माता पिता पर कब्जा जब अनुरोध यह पर ध्यान केंद्रित करने के लिए एनीमेशन का उपयोग करने की आवश्यकता है। सही? –
@ रमन हां.मैंने आपके उत्तर के साथ प्रयास किया है, लेकिन ऐसा नहीं था। – asish