2013-07-24 6 views
8

मैंने पुन: उत्पन्न होने पर सबसे छोटी उदाहरण में अपनी समस्या को सरल बना दिया।डायलॉग के कीबोर्ड गायब होने के बाद वीडियो व्यू ठीक से प्रस्तुत नहीं किया गया है

तो: VideoView और imageView साथ

  • 1 गतिविधि।
  • ImageView AlertDialog पर क्लिक करने के बाद दिखाया गया है।
  • अलर्टडिअलॉग में 1 संपादन टेक्स्ट क्षेत्र है।
  • मैं इस संपादन टेक्स्ट को स्पर्श करता हूं और मानक एंड्रॉइड कीबोर्ड दिखाया जाता है।
  • कीबोर्ड बंद करें।
  • बंद संवाद।

समस्या: VideoView की सीमाओं (काला आयत) का विस्तार हुआ और इस प्रकार imageView अब पता चला है नहीं है।

किसी भी मदद की सराहना की जाती है! धन्यवाद।

BEFORE AFTER

कोड:

MainActivity.java

import android.app.Activity; 
import android.app.AlertDialog; 
import android.os.Bundle; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.VideoView; 

public class MainActivity extends Activity { 
@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    final Activity act = this; 
    final VideoView videoView = (VideoView) findViewById(R.id.videoView1); 
    videoView.setVideoPath("/mnt/sdcard/s1ep01.mp4"); 
    videoView.requestFocus(); 
    findViewById(R.id.imageView1).setOnClickListener(new OnClickListener() { 
     @Override 
     public void onClick(View arg0) { 
      AlertDialog.Builder builder = new AlertDialog.Builder(act); 
      View view = LayoutInflater.from(act).inflate(R.layout.dialog, null); 
      builder.setView(view); 
      builder.setPositiveButton("Save translation", null); 
      builder.setNegativeButton("Cancel", null); 
      AlertDialog dialog = builder.create(); 
      dialog.show(); 
     } 
    }); 
} 
} 

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context=".MainActivity" > 

<VideoView 
    android:id="@+id/videoView1" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_centerInParent="true" /> 

<ImageView 
    android:id="@+id/imageView1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_above="@+id/videoView1" 
    android:src="@android:drawable/btn_dialog" /> 

</RelativeLayout> 

dialog.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="wrap_content"> 

<EditText 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" /> 

</RelativeLayout> 
+0

मुझे लगता है कि इस मामले में मैनिफेस्ट 'एंड्रॉइड में आपकी गतिविधि में शामिल होना सुरक्षित है: windowSoftInputMode = "adjustNothing" '। –

उत्तर

3

एक अस्थायी समाधान के रूप में, मैं एक Runnable कि VideoView अदृश्य बनाता है बनाया है, तो बनाता है 200 मिली यह दृष्टिगोचर के बाद सेकंड:

// Hide the VideoView 
videoLayout.setVisibility(View.INVISIBLE); 

// create a handler to handle the delayed runnable request 
new Handler().postDelayed(new Runnable() { 

    @Override 
    public void run() { 
     // After the 200 millis (which are passes as a second parameter to this postDelayed() method in the last line of the code, this handler will invoke the following method : 

     // run on UI so you can set the Visibitity of the UI elements 
     runOnUiThread(new Runnable() { 
    @Override 
      public void run() {videoLayout.setVisibility(View.VISIBLE);} // make it visible again 
}); 
    } 
}, 200); // this is the second parameter which decides when this handler will run it's run() method 

आशा है कि यह अस्थायी समाधान अब

कॉल इस के लिए मदद करता है जब आपका कीबोर्ड छुपा रहा है, तो एन्टर कुंजी पर समान रूप से, या जब आप इसे छुपाने के लिए कुंजीपटल के बाहर एक निश्चित दृश्य को स्पर्श करते हैं ... लेकिन इसे गतिविधि के ऑन टचएवेंट() में या ऑनयूसर इंटरैक्शन में न रखें ताकि फ्लैशिंग

चमक न रखें
+0

1- प्रश्न पर मेरी टिप्पणी पढ़ें। 2- मुझे लगता है कि 'अनुरोध Layout();' देरी से चलने योग्य पोस्ट करने के बजाय पर्याप्त है। –

+0

लेकिन अगर यह कुछ भी समायोजित नहीं करता है, तो मेरा संपादन टेक्स्ट नरम इनपुट कीबोर्ड द्वारा कवर किया जाएगा! ... मैं एक रननेबल पोस्ट करने के बजाय अनुरोध Layout() का प्रयास करूंगा ... आप इसका मतलब यह है कि इसके बजाय उसी परिस्थितियों में इसका उपयोग करें ... जो मैं आपको समझता हूं –

+1

बस 'एंड्रॉइड: windowSoftInputMode' के साथ खेलें। मुझे लगता है कि यह आपके लिए नौकरी कर सकता है: http://www.sherif.mobi/2011/10/softkeyboard-problem-with-tabhost-on.html –

संबंधित मुद्दे