Git Product home page Git Product logo

Comments (7)

AndroidDeveloperLB avatar AndroidDeveloperLB commented on August 17, 2024

Another way to check it is to use a scrollView as the custom view of the dialog.
This one can even occur on normal screens.

example:

final AlertDialogPro.Builder builder=new AlertDialogPro.Builder(activity,...);
builder.setTitle(...);
final TextView textView=new TextView(activity);
textView.setTextSize(TypedValue.COMPLEX_UNIT_SP,18);
final ScrollView sv=new ScrollView(activity);
sv.addView(textView);
final int padding=(int)ViewUtil.convertDpToPixels(4);
sv.setPadding(padding,padding,padding,padding);
sv.setFillViewport(true);
builder.setView(sv);
textView.setTextColor(...);
textView.setText(...);  // <=really long text with lots of lines
textView.setMovementMethod(LinkMovementMethod.getInstance());
textView.setClickable(true);
builder.setPositiveButton(android.R.string.ok,null);
builder.show();

from alertdialogpro.

AndroidDeveloperLB avatar AndroidDeveloperLB commented on August 17, 2024

I think adding a weight to "customPanel" would fix this:

  <FrameLayout
      android:id="@+id/customPanel"
      android:layout_width="match_parent"
      android:layout_height="0px"
      android:layout_weight="1" />

Also, here's a layout I've used in the past, with ActionBarSherlock. It might be of help.
Speaking of this layout, why did you make a new LinearLayout? the support library already has this. Is it so that it would support more Android versions?

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/alertDialog__parentPanel"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="vertical"
    tools:context=".MainActivity" >

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

    <LinearLayout
        android:id="@+id/alertDialog__titleTemplate"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_marginLeft="16dp"
        android:layout_marginRight="16dp"
        android:gravity="center_vertical|start"
        android:minHeight="@dimen/abs__alert_dialog_title_height"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/alertDialog__icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:paddingLeft="4dp"
            android:paddingRight="4dp"
            android:src="@android:drawable/sym_def_app_icon" />

        <com.lb.app_manager.utils.alert_dialog.DialogTitle
            android:id="@+id/alertDialog__alertTitle"
            style="@style/DialogWindowTitle.Sherlock.Light"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:ellipsize="end"
            android:gravity="center_vertical"
            android:singleLine="true"
            android:text="title"
            tools:ignore="HardcodedText" />
    </LinearLayout>

    <View
        android:id="@+id/alertDialog__titleDivider"
        android:layout_width="match_parent"
        android:layout_height="2dip"
        android:background="@color/abs__holo_blue_light"
        android:visibility="visible" />
    <!-- If the client uses a customTitle, it will be added here. -->
</LinearLayout>

<ScrollView
    android:id="@+id/alertDialog__contentPanel"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:clipChildren="false"
    android:clipToPadding="false"
    android:minHeight="64dp" >

    <TextView
        android:id="@+id/alertDialog__message"
        style="?android:attr/textAppearanceMedium"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="top"
        android:paddingBottom="8dip"
        android:paddingLeft="16dp"
        android:paddingRight="16dp"
        android:paddingTop="8dip"
        android:text="message"
        tools:ignore="HardcodedText" />
</ScrollView>

<FrameLayout
    android:id="@+id/alertDialog__customPanel"
    android:layout_width="match_parent"
    android:layout_height="0px"
    android:layout_weight="1" />

<ImageView
    android:id="@+id/alertDialog__dividerAboveButtonsView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:adjustViewBounds="false"
    android:scaleType="fitXY"
    android:src="?attr/alert_dialog_divider" />

<com.actionbarsherlock.internal.widget.IcsLinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:divider="?attr/alert_dialog_divider"
    android:gravity="center_horizontal"
    android:measureWithLargestChild="true"
    android:orientation="horizontal"
    android:showDividers="middle|beginning|end"
    tools:ignore="UnusedAttribute,MissingRegistered" >

    <Button
        android:id="@+id/alertDialog__negativeButton"
        android:layout_width="0px"
        android:layout_height="wrap_content"
        android:layout_gravity="start"
        android:layout_weight="1"
        android:background="?attr/selectableItemBackground"
        android:gravity="center"
        android:maxLines="2"
        android:minHeight="@dimen/alert_dialog_button_bar_height"
        android:textColor="?android:textColorPrimary"
        android:textSize="14sp" />

    <Button
        android:id="@+id/alertDialog__neutralButton"
        android:layout_width="0px"
        android:layout_height="wrap_content"
        android:layout_gravity="center_horizontal"
        android:layout_weight="1"
        android:background="?attr/selectableItemBackground"
        android:gravity="center"
        android:maxLines="2"
        android:minHeight="@dimen/alert_dialog_button_bar_height"
        android:textColor="?android:textColorPrimary"
        android:textSize="14sp" />

    <Button
        android:id="@+id/alertDialog__positiveButton"
        android:layout_width="0px"
        android:layout_height="wrap_content"
        android:layout_gravity="end"
        android:layout_weight="1"
        android:background="?attr/selectableItemBackground"
        android:gravity="center"
        android:maxLines="2"
        android:minHeight="@dimen/alert_dialog_button_bar_height"
        android:textColor="?android:textColorPrimary"
        android:textSize="14sp" />
</com.actionbarsherlock.internal.widget.IcsLinearLayout>

from alertdialogpro.

fengdai avatar fengdai commented on August 17, 2024

Yes, that can be fixed by adding a weight to "customPanel". You can also do this in the code by replacing builder.show() with below code:

AlertDialogPro alertDialogPro = builder.create();
alertDialogPro.show();
((LinearLayout.LayoutParams)
            alertDialogPro.getWindow().findViewById(R.id.customPanel).getLayoutParams()).weight = 1;

BTW:
If you just want a multi choice ListView, I suggest you to use the setMultiChoiceItems API instead of setting a custom ListView. It works fine.

from alertdialogpro.

fengdai avatar fengdai commented on August 17, 2024

why did you make a new LinearLayout?

Firstly, the alertdialogpro module doesn't depend on the appcompat-v7. It's not necessary to do this. So I just ported the LinearLayoutICS.java from appcompat-v7.

Secondly, Sometime ago, when I tried to make this project, the LinearLayoutICS.java of appcompat-v7 was not visible at that time. It was hided by@hide tag. Recently Google makes it visible in version 21.

from alertdialogpro.

AndroidDeveloperLB avatar AndroidDeveloperLB commented on August 17, 2024

About the weight,please put it in your code too. It's a bug since the dialog should show its buttons if I choose to show them...

About the listView, I've made more than just multi-choice. You can check out my app to see the various dialogs there:
https://play.google.com/store/apps/details?id=com.lb.app_manager

About the LinearLayout, I see. Makes sense.

from alertdialogpro.

fengdai avatar fengdai commented on August 17, 2024

Done: 60d38d2

from alertdialogpro.

AndroidDeveloperLB avatar AndroidDeveloperLB commented on August 17, 2024

Cool. I made a difference :)

from alertdialogpro.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.