LinearLayout未显示在特定设备上

时间:2016-02-15 18:39:20

标签: android android-layout

某些情境:

我的应用程序发生了一些怪异的事情。我有一个LinearLayout,里面有两个ToggleButtons。我在运行Android 6.0的LG G4上测试它(之前的5.1也是功能的),两个按钮都没有问题。当我构建一个签名的APK并将其安装在运行5.1.1的三星Galaxy S6上时,我遇到了这个问题。在此设备上,到目前为止仅此设备,LinearLayout未显示!

我尝试过:

  • 在活动onCreate方法
  • 中对布局和按钮的可见性进行硬编码
  • 在活动的布局xml中对布局和按钮的可见性进行硬编码
  • LinearLayout
  • 替换RelativeLayout
  • 搜索并随后谷歌搜索/搜索基本上每行相关输出

Logcat日志

一旦我按下按钮将我带到违规布局未显示的活动,就会从三星S6开始错误日志

02-15 10:56:15.799 20301-20301/com.MyApp.android D/ViewRootImpl: ViewPostImeInputStage ACTION_DOWN
02-15 10:56:15.959 20301-20301/com.MyApp.android I/Timeline: Timeline: Activity_launch_request id:com.MyApp.android time:49138619
02-15 10:56:15.999 20301-20301/com.MyApp.android D/PhoneWindow: *FMB* installDecor mIsFloating : false
02-15 10:56:15.999 20301-20301/com.MyApp.android D/PhoneWindow: *FMB* installDecor flags : 8454400
02-15 10:56:16.019 20301-20301/com.MyApp.android D/AbsListView: Get MotionRecognitionManager
02-15 10:56:16.019 20301-20301/com.MyApp.android D/lantern: bind - activity: false  connected: false
02-15 10:56:16.029 20301-20301/com.MyApp.android D/Activity: performCreate Call Injection manager
02-15 10:56:16.029 20301-20301/com.MyApp.android I/InjectionManager: dispatchOnViewCreated > Target : com.MyApp.android.activities.ResultsActivity isFragment :false
02-15 10:56:16.039 20301-20301/com.MyApp.android D/SecWifiDisplayUtil: Metadata value : SecSettings2
02-15 10:56:16.049 20301-20301/com.MyApp.android D/PhoneWindow: *FMB* isFloatingMenuEnabled mFloatingMenuBtn : null
02-15 10:56:16.049 20301-20301/com.MyApp.android D/PhoneWindow: *FMB* isFloatingMenuEnabled return false
02-15 10:56:16.069 20301-20301/com.MyApp.android D/SRIB_DCS: log_dcs ThreadedRenderer::initialize entered! 
02-15 10:56:16.069 20301-20351/com.MyApp.android D/mali_winsys: new_window_surface returns 0x3000,  [1440x2560]-format:1
02-15 10:56:16.089 20301-20301/com.MyApp.android D/lantern: onConnected - activity: true
02-15 10:56:16.089 20301-20301/com.MyApp.android D/lantern: onConnected - location: null
02-15 10:56:16.109 20301-20438/com.MyApp.android I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
02-15 10:56:16.109 20301-20438/com.MyApp.android I/System.out: (HTTPLog)-Static: isShipBuild true
02-15 10:56:16.109 20301-20438/com.MyApp.android I/System.out: (HTTPLog)-Thread-33529-429041145: SmartBonding Enabling is false, SHIP_BUILD is true, log to file is false, DBG is false
02-15 10:56:16.109 20301-20438/com.MyApp.android I/System.out: (HTTPLog)-Thread-33529-429041145: SMARTBONDING_FEATURE_ENABLED is true
02-15 10:56:16.109 20301-20438/com.MyApp.android I/System.out: (HTTPLog)-Static: isSBSettingEnabled false
02-15 10:56:16.109 20301-20438/com.MyApp.android I/System.out: KnoxVpnUidStorageknoxVpnSupported API value returned is false
02-15 10:56:16.109 20301-20438/com.MyApp.android I/System.out: KnoxVpnUidStorageknoxVpnSupported API value returned is false
02-15 10:56:16.129 20301-20301/com.MyApp.android I/InjectionManager: dispatchCreateOptionsMenu :com.MyApp.android.activities.ResultsActivity
02-15 10:56:16.129 20301-20301/com.MyApp.android I/InjectionManager: dispatchPrepareOptionsMenu :com.MyApp.android.activities.ResultsActivity
02-15 10:56:16.129 20301-20301/com.MyApp.android I/InjectionManager: dispatchPrepareOptionsMenu :com.MyApp.android.activities.ResultsActivity
02-15 10:56:16.179 20301-20301/com.MyApp.android I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@1f360f65 time:49138846
02-15 10:56:18.579 20301-20301/com.MyApp.android D/ListView: change accessibility focus position = 0
02-15 10:56:26.089 20301-20443/com.MyApp.android D/lantern: Timer has run. Connected: true
02-15 10:56:26.099 20301-20301/com.MyApp.android D/lantern: Remove timer tasks
02-15 10:56:26.099 20301-20301/com.MyApp.android D/lantern: Request balanced location updates
02-15 10:56:46.549 20301-20301/com.MyApp.android V/ActivityThread: updateVisibility : ActivityRecord{35b69275 token=android.os.BinderProxy@1f360f65 {com.MyApp.android/com.MyApp.android.activities.ResultsActivity}} show : true

我的G4是一个良好的日志,这是一个布局确实出现的设备:

02-15 10:44:36.382 5966-5966/com.MyApp.android I/ViewRootImpl: ViewRoot's Touch Event : ACTION_DOWN
02-15 10:44:36.405 5966-5966/com.MyApp.android I/ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
02-15 10:44:36.409 5966-5966/com.MyApp.android I/AudioManagerEx: AudioManagerEx created
02-15 10:44:36.419 5966-5966/com.MyApp.android I/Timeline: Timeline: Activity_launch_request id:com.MyApp.android time:102565694
02-15 10:44:36.472 5966-5966/com.MyApp.android W/SplitWindow: update focus... 
02-15 10:44:36.500 5966-5966/com.MyApp.android D/PhoneWindowEx: Ex2. SystemProperties.get result >> #ff000000
02-15 10:44:36.657 5966-5966/com.MyApp.android D/lantern: bind - activity: false    connected: false
02-15 10:44:36.711 5966-5966/com.MyApp.android D/lantern: onConnected - activity: true
02-15 10:44:36.739 5966-6082/com.MyApp.android W/art: Failed to open zip archive '/system/framework/qcom.fmradio.jar': I/O Error
02-15 10:44:36.739 5966-6082/com.MyApp.android W/art: Failed to open zip archive '/system/framework/oem-services.jar': I/O Error
02-15 10:44:36.758 5966-6082/com.MyApp.android D/libc: getaddrinfo called from pid =5966
02-15 10:44:36.758 5966-6082/com.MyApp.android D/libc: getaddrinfo called from pid =5966
02-15 10:44:36.782 5966-5966/com.MyApp.android D/lantern: onConnected - location: (33.7568342,-84.3645554) within 169.086 meters
02-15 10:44:36.842 5966-5966/com.MyApp.android W/SplitWindow: update focus... 
02-15 10:44:36.844 5966-5966/com.MyApp.android D/Editor: setInputTypeforClipTray(): 0
02-15 10:44:36.874 5966-5966/com.MyApp.android V/ViewRootImpl: Contents drawing finished : com.MyApp.android/com.MyApp.android.activities.ResultsActivity
02-15 10:44:36.914 5966-5966/com.MyApp.android E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
02-15 10:44:36.914 5966-5966/com.MyApp.android E/SpannableStringBuilder: SPAN_EXCLUSIVE_EXCLUSIVE spans cannot have a zero length
02-15 10:44:36.915 5966-5966/com.MyApp.android I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@64a0c0d time:102566189
02-15 10:44:36.924 5966-6082/com.MyApp.android D/libc: getaddrinfo called from pid =5966

代码

以下是活动 XML

的布局
<LinearLayout
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="50dp"
        android:background="@color/white"
        android:layout_below="@+id/imgStation"
        android:layout_alignParentLeft="true"
        android:layout_alignParentStart="false"
        android:id="@+id/layout_sort_options"
        android:visibility="visible">

        <ToggleButton
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:text="@string/name"
            android:id="@+id/btnSortName"
            android:layout_weight="1"
            style="@style/Button.Sort"
            android:checked="true"
            android:textOff="Name"
            android:textOn="Name"
            android:onClick="pressedSortName"
            android:clickable="true"
            android:visibility="visible" />

        <ToggleButton
            android:layout_width="fill_parent"
            android:layout_height="match_parent"
            android:text="@string/distance"
            android:id="@+id/btnSortDistance"
            android:layout_weight="1"
            style="@style/Button.Sort"
            android:checked="true"
            android:textOff="Distance"
            android:textOn="Distance"
            android:onClick="pressedSortDistance"
            android:clickable="true"
            android:visibility="visible" />

    </LinearLayout>

此处活动的 onCreate() 方法或多或少看起来像这样:

public class myActivity {
    private LinearLayout m_layout_sort_options;
    private ToggleButton m_btnSortName;
    private ToggleButton m_btnSortDistance;

    protected void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);

    m_layout_sort_options = (LinearLayout)findViewById(R.id.layout_sort_options);
    m_btnSortName = (ToggleButton)findViewById(R.id.btnSortName);
    m_btnSortDistance = (ToggleButton)findViewById(R.id.btnSortDistance);

    //here is the hard-coding which attempts to default the visibility of the buttons and layout
    m_btnSortDistance.setVisibility(View.VISIBLE);
    m_btnSortDistance.setVisibility(View.VISIBLE);
    m_layout_sort_options.setVisibility(View.VISIBLE);

    }
}

困境

所以我真正能说的是,布局,尽管它是什么类型,并没有出现在三星Galaxy S6上,但它在我的其他设备上显示得很好。我在这里看到了其他一些关于此的帖子,但答案似乎并不适用于我的情况。如果有人遇到这样的问题,请发布您可以回忆的任何信息!

0 个答案:

没有答案