1

解決済み:

私は自分の問題を解決しました。目的の機能を得るために、別のことをしました。scrollViewにtabHostがあることが問題であることが判明しましたが、テストした限り、Android 4.0以降の問題のみです。以下のコードを使用すると、タブウィジェットを「縮小」して、アプリを「フルスクリーン」にすることができます。これがいつか誰かのxDに役立つことを願っています。

public class MyScaler extends ScaleAnimation
{
    private View         mView;

    private LayoutParams mLayoutParams;

    private int          mMarginBottomFromY, mMarginBottomToY;

    private boolean      mVanishAfter = false;

    public MyScaler(float fromX, float toX, float fromY, float toY, int duration, View view, boolean vanishAfter)
    {
        super(fromX, toX, fromY, toY);
        setDuration(duration);
        mView = view;
        mVanishAfter = vanishAfter;
        mLayoutParams = (LayoutParams) view.getLayoutParams();
        final int height = mView.getHeight();

        if(fromY > toY)
        {
            mMarginBottomFromY = (int) (height * fromY) + mLayoutParams.bottomMargin - height;
            mMarginBottomToY = (int) (0 - ((height * toY) + mLayoutParams.bottomMargin)) - height;

        }
        else
        {
            mMarginBottomFromY = mLayoutParams.bottomMargin;
            mMarginBottomToY = 0;
            mView.setVisibility(View.VISIBLE);
        }

    }

    @Override
    protected void applyTransformation(float interpolatedTime, Transformation t)
    {
        super.applyTransformation(interpolatedTime, t);

        if (interpolatedTime < 1.0f)
        {
            int newMarginBottom = mMarginBottomFromY + (int) ((mMarginBottomToY - mMarginBottomFromY) * interpolatedTime);
            mLayoutParams.setMargins(mLayoutParams.leftMargin, mLayoutParams.topMargin, mLayoutParams.rightMargin, newMarginBottom);
            mView.getParent().requestLayout();
        }
        else if (mVanishAfter)
        {
            mView.setVisibility(View.GONE);
        }
        else if(!mVanishAfter)
        {
            mLayoutParams.setMargins(mLayoutParams.leftMargin, mLayoutParams.topMargin, mLayoutParams.rightMargin, 0);
            mView.getParent().requestLayout();
        }

    }



}

こんにちは :) 私は Android/iOS を 1 年余り使用しており、趣味で C/C++ を 5 回ほど使用しています。問題のこのコードも趣味のプロジェクトです。

かなり具体的な質問があります...現在、Galaxy Nexusでアプリを開発しています.Android 4.01をそのまま実行しています.4.02でもこれをテストしました-同じ.

私の問題は次のとおりです。

BaseAdapter のサブクラスを使用して、リストビューの LineayLayouts にいくつかの edittext ビューがあります。このビューをダブルクリックまたは「ロングクリック」し、テキストが含まれていると、アプリがクラッシュして IllegalStateException がスローされます。以下のコール スタックを参照してください。通常、これにより (Android 4.0 以降で、おそらく 3.2 以降)、さまざまなコピー/貼り付けオプションを含むオプション バーが作成されます。

私のアプリは、4 つのタブを持つ Tabactivity で構成されています。これらのタブは、4 つの「子アクティビティ」によって作成されます。「フルスクリーン」にしてタブウィジェットを削除できるようにするために、タブホストはスクロールビューに囲まれていますが、それが問題だとは思いません。私の問題は 4 つのタブすべてにあります。

上記のすべては、HTC Desire、Samsung Galaxy S 2、HTC Hero、および 2.3.3 を実行するエミュレーターを含む、他の 4 つのデバイスで完全に動作します。(処理能力の 1/8 しか使用しないため、i7 1.6 クワッドで 4.0 エミュレーターを実行できません)

ただし、AlertDialog のようなポップアップに Edittext-view がある場合、テキストをマークするためのダブルクリック/ロングクリック機能は問題なく機能し、画面上部の新しい 4.0 バーには切り取り、コピーなどのオプションが表示されます、および貼り付けがポップアップ表示され、問題なく動作します。

自分自身やウェブで解決策を検索しようとしましたが、情報を見つけることができませんでした。以前に edittext と Listviews で問題を経験したことがある人がいることがわかりました。そして、Listview の代わりに、LinearLayouts の Edittext ビューを 1 つの巨大な LinearLayout に配置しようとしましたが、これは何の違いもありませんでした。

どんな入力でも大歓迎です!さらに情報が必要な場合は教えてください。:) どうも :)

編集:

さらに調査を行い、まったく同じレイアウトのアプリを構築しようとしましたが、タブホストを囲むスクロールビューはありません。これは機能します。しかし、レイアウトの大部分を書き直さない限り、問題は解決しません。

これは私の Main.xml です

<my.pack.MyScrollView xmlns:android="http://schemas.android.com/apk/res/android">          

    <LinearLayout android:orientation="vertical" android:id="@+id/ScrollLayout"
        android:layout_width="match_parent" android:layout_height="wrap_content">

        <TabHost 
            android:id="@android:id/tabhost"   android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <LinearLayout android:orientation="vertical"
                android:layout_width="match_parent" android:layout_height="wrap_content">

                <HorizontalScrollView xmlns:android="http://schemas.android.com/apk/res/android"
                    android:id="@+id/tabs" android:layout_width="fill_parent"
                    android:layout_height="wrap_content" android:padding="0px"
                    android:layout_margin="0px" android:background="@drawable/horizontaltabbackground">

                    <TabWidget android:id="@android:id/tabs"
                        android:layout_width="fill_parent" android:layout_height="wrap_content"
                        android:padding="0px" android:layout_margin="0px" />

                </HorizontalScrollView>

                <FrameLayout android:id="@android:id/tabcontent"
                    android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="#ff000000"/>

            </LinearLayout>

        </TabHost>

    </LinearLayout>

</my.pack.MyScrollView>

Eclipse からのコール スタック:

Thread [<1> main] (Suspended (exception IllegalStateException)) 
    ActionBarContextView.onMeasure(int, int) line: 328  
    ActionBarContextView(View).measure(int, int) line: 12603    
    LinearLayout(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 4677    
    LinearLayout.measureChildBeforeLayout(View, int, int, int, int, int) line: 1369 
    LinearLayout.measureVertical(int, int) line: 660    
    LinearLayout.onMeasure(int, int) line: 553  
    LinearLayout(View).measure(int, int) line: 12603    
    PhoneWindow$DecorView(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 4677   
    PhoneWindow$DecorView(FrameLayout).onMeasure(int, int) line: 293    
    PhoneWindow$DecorView.onMeasure(int, int) line: 2072    
    PhoneWindow$DecorView(View).measure(int, int) line: 12603   
    FrameLayout(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 4677 
    FrameLayout.onMeasure(int, int) line: 293   
    FrameLayout(View).measure(int, int) line: 12603 
    LinearLayout(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 4677    
    LinearLayout.measureChildBeforeLayout(View, int, int, int, int, int) line: 1369 
    LinearLayout.measureVertical(int, int) line: 660    
    LinearLayout.onMeasure(int, int) line: 553  
    LinearLayout(View).measure(int, int) line: 12603    
    TabHost(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 4677 
    TabHost(FrameLayout).onMeasure(int, int) line: 293  
    TabHost(View).measure(int, int) line: 12603 
    LinearLayout(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 4677    
    LinearLayout.measureChildBeforeLayout(View, int, int, int, int, int) line: 1369 
    LinearLayout.measureVertical(int, int) line: 660    
    LinearLayout.onMeasure(int, int) line: 553  
    LinearLayout(View).measure(int, int) line: 12603    
    MyScrollView(ScrollView).measureChildWithMargins(View, int, int, int, int) line: 1163   
    MyScrollView(FrameLayout).onMeasure(int, int) line: 293 
    MyScrollView(ScrollView).onMeasure(int, int) line: 312  
    MyScrollView(View).measure(int, int) line: 12603    
    FrameLayout(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 4677 
    FrameLayout.onMeasure(int, int) line: 293   
    FrameLayout(View).measure(int, int) line: 12603 
    LinearLayout(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 4677    
    LinearLayout.measureChildBeforeLayout(View, int, int, int, int, int) line: 1369 
    LinearLayout.measureVertical(int, int) line: 660    
    LinearLayout.onMeasure(int, int) line: 553  
    LinearLayout(View).measure(int, int) line: 12603    
    PhoneWindow$DecorView(ViewGroup).measureChildWithMargins(View, int, int, int, int) line: 4677   
    PhoneWindow$DecorView(FrameLayout).onMeasure(int, int) line: 293    
    PhoneWindow$DecorView.onMeasure(int, int) line: 2072    
    PhoneWindow$DecorView(View).measure(int, int) line: 12603   
    ViewRootImpl.performTraversals() line: 1044 
    ViewRootImpl.handleMessage(Message) line: 2418  
    ViewRootImpl(Handler).dispatchMessage(Message) line: 99 
    Looper.loop() line: 137 
    ActivityThread.main(String[]) line: 4340    
    Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]  
    Method.invoke(Object, Object...) line: 511  
    ZygoteInit$MethodAndArgsCaller.run() line: 784  
    ZygoteInit.main(String[]) line: 551 
    NativeStart.main(String[]) line: not available [native method]  
4

0 に答える 0