我有一个奇怪的问题,我不知道如何解决.我在ScrollView中有一个RelativeLayout,这个scrollView的高度设置为fill_parent.RelativeLayout也是如此.尽管如此,内容并没有填满整个屏幕,它只会进入此RelativeLayout中最后一个布局的wrap_content.
这是我的代码:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.pontai"
android:id="@+id/relativeLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent" >
<RelativeLayout
android:id="@+id/relativeLayout2"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<LinearLayout
android:id="@+id/linearLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/relativeLayout3"
android:layout_alignParentTop="true"
android:layout_alignRight="@+id/relativeLayout5"
android:layout_marginTop="5dp"
android:orientation="horizontal" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="How much points you have here:"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:id="@+id/textViewTotalPoints1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="120"
android:textAppearance="?android:attr/textAppearanceMedium" />
</LinearLayout>
<RelativeLayout
android:id="@+id/relativeLayout4"
android:layout_width="wrap_content"
android:layout_height="80dp"
android:layout_alignLeft="@+id/relativeLayout3"
android:layout_below="@+id/linearLayout1"
android:layout_marginTop="5dp"
android:layout_toLeftOf="@+id/textView7"
android:orientation="vertical" >
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="5dp"
android:text="Ratings"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/textViewPositivePoints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="25dp" …Run Code Online (Sandbox Code Playgroud) android android-layout android-scrollview android-relativelayout
我有一个应用程序,它根据定义的边界在GoogleMaps中随机生成位置.所以我首先生成一个随机的LatLng,然后我验证这个点是否在我的边界内.如果是,它是有效的.
Builder builder = new LatLngBounds.Builder();
double antartica[] = {-62.5670958528642, -59.92767333984375, -62.584805850293485, -59.98260498046875, -62.61450963659083};
for (int i = 0; i < antartica.length; i++) {
builder.include(new LatLng(antartica[i],antartica[++i]));
}
pAntarctica = builder.build();
LatLng point = generateRandomPosition();
if(isWithinBoundaries(point))
return point;
else
return getValidPoint();
Run Code Online (Sandbox Code Playgroud)
所以在此之后,我最终得到了有效点.我的问题是,Google地图中的有效点在StreetView中不一定有效.可能会发生这个随机点在地球上的某个地方尚未映射到StreetView中.我也需要它在那里有效.
我知道您可以通过以下链接使用JavaScript API v3来完成此操作:https: //developers.google.com/maps/documentation/javascript/reference#StreetViewService
你会做这样的事情:
var latLng = new google.maps.LatLng(12.121221, 78.121212);
streetViewService.getPanoramaByLocation(latLng, STREETVIEW_MAX_DISTANCE, function (streetViewPanoramaData, status) {
if (status === google.maps.StreetViewStatus.OK) {
//ok
} else {
//no ok
}
});
Run Code Online (Sandbox Code Playgroud)
但我希望只使用Android来做到这一点.我顺便使用Google Play Services API,而不是 Google Maps …
我有一个RelativeLayout,我有一个TextView,这个元素的android:layout_toLeftOf属性设置为同一布局中的另一个TextView.
根据应用程序从服务器收到的数据,我需要设置这一个TextView GONE的可见性并设置一个ProgressBarto 的可见性,VISIBLE然后我需要第一个TextView左对齐此进度条.
这可能以编程方式完成吗?
如果没有,你能想出办法来解决这个问题吗?
编辑
根据以下建议,这是我的工作代码的样子:
TextProgressBar txtProgressBar = (TextProgressBar) v.findViewById(R.id.progressBarPointsInProgress);
TextView offerName = (TextView) v.findViewById(R.id.textViewOfferName);
android.widget.RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams)offerName.getLayoutParams();
params.addRule(RelativeLayout.LEFT_OF, R.id.progressBarPointsInProgress);
params.addRule(RelativeLayout.ALIGN_PARENT_LEFT);
offerName.setLayoutParams(params);
Run Code Online (Sandbox Code Playgroud) 这是我努力工作的流程:
所以,对于这个解决方案,我使用的是RestFB(http://restfb.com/)和Facebook Android API v3.0
当用户单击"赞"按钮时,我会执行以下操作:
private Session.StatusCallback callback =
new Session.StatusCallback() {
@Override
public void call(Session session, SessionState state, Exception exception) {
//facebookClient is the RestFB object
facebookClient = new DefaultFacebookClient(session.getAccessToken());
Intent i = new Intent(MainActivity.this, FacebookWebViewActivity.class);
startActivity(i);
}
};
Run Code Online (Sandbox Code Playgroud)
使用此代码,我可以成功登录Facebook(获取AUTH_CODE)然后我调用我的WebView,它应该将用户引导到我想要的粉丝页面.这个WebView活动非常简单,只需:
webView.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {
Intent intent = new Intent(FacebookWebViewActivity.this, MainActivity.class);
startActivity(intent);
return true; …Run Code Online (Sandbox Code Playgroud) 在我的三星Galaxy Nexus上,行为还可以,它显示三个点,但在三星S2中,它只显示一个点.只有一个布局文件:
<TextView
android:id="@+id/textViewOfferTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_toLeftOf="@+id/textViewRedemptionDate"
android:layout_alignParentLeft="true"
android:ellipsize="end"
android:singleLine="true"
android:textColor="@color/pontai_dark_gray"
android:textSize="@dimen/ndp_font_size" />
Run Code Online (Sandbox Code Playgroud)
这是一个例子:
http://img109.imageshack.us/img109/5118/96452147.png
有没有人见过这个?
我知道这个问题已经在这里多次询问,但是在花了最后1.5小时阅读并试图解决我的问题后,我不能.
问题陈述:
setStyle在DialogFragmenti中调用方法时,会在标题中声明RuntimeException错误.
这是我的原始代码,它不会抛出此异常:
public class MapDialogFragment extends DialogFragment
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme_Holo);
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
view = inflater.inflate(R.layout.maps_dialog, container, false);
return view;
}
}
Run Code Online (Sandbox Code Playgroud)
现在,我刚刚在我的应用程序中添加了ImmersiveMode.正如你们中的一些人可能知道的那样,沉浸式模式在显示Dialogs时会丢失,因此必须覆盖这些片段并设置适当的标志以保持模式.我成功地完成了这项工作 - 它有效.但是,我必须评论一下:setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme_Holo);所以我失去了对话框的风格,这就是问题所在.
仔细看看setStyleDialogFragment 中的方法,我无法真正看到如何requestFeature()调用它:
public void setStyle(int style, int theme) {
mStyle = style;
if (mStyle == STYLE_NO_FRAME || mStyle == STYLE_NO_INPUT) {
mTheme = com.android.internal.R.style.Theme_DeviceDefault_Dialog_NoFrame;
}
if (theme != 0) …Run Code Online (Sandbox Code Playgroud) 我有以下布局:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.pontai"
android:id="@+id/linearLayout1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<com.markupartist.android.widget.ActionBar
android:id="@+id/actionbar"
style="@style/ActionBar"
android:layout_marginBottom="3dip"
app:textStyleActionBar="@style/TextViewStyleHeader"
app:title="@string/app_name" />
<com.fb.design.SegmentedButton
android:id="@+id/main_action_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:btnText1="@string/sb_friends"
app:btnText2="@string/sb_search"
app:btnText3="@string/sb_summary"
app:gradientColorOffEnd="@color/segmented_button_off_end"
app:gradientColorOffStart="@color/segmented_button_off_start"
app:gradientColorOnEnd="@color/segmented_button_on_end"
app:gradientColorOnStart="@color/segmented_button_on_start"
app:gradientColorSelectedEnd="@color/segmented_button_selected_end"
app:gradientColorSelectedStart="@color/segmented_button_selected_start"
app:whichButtonIsSelected="0" />
<View
android:layout_width="wrap_content"
android:layout_height="2dp"
android:layout_marginBottom="3dip"
android:background="@drawable/gradient_line" >
</View>
<LinearLayout
android:id="@+id/linearLayout7"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<LinearLayout
android:id="@+id/linearLayout4"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<Button
android:id="@+id/buttonAddFriends"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/ic_input_add"
android:clickable="true"
android:height="40dp"
android:width="40dp" />
<EditText
android:id="@+id/search_box"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:hint="@string/type_here_to_filter"
android:inputType="text"
android:maxLines="1"
android:padding="10dp" >
</EditText>
</LinearLayout>
<LinearLayout
android:id="@+id/loadingPanel"
style="@style/GenericProgressBackground"
android:layout_height="match_parent" >
<ProgressBar style="@style/GenericProgressIndicator" />
</LinearLayout>
<ListView …Run Code Online (Sandbox Code Playgroud) 我的设计师给了我以下布局(稍微改变以保护我的业务:)

现在,我面临很多疑问,因为我可以将每个元素合并到我的android布局中.
如您所见,背景有轻微的噪音.我尝试从它创建一个9patch,但在Android中加载时,我完全失去了成像的质量.它奇怪地伸展开来.我应该为不同的分辨率设置一个背景(即mdpi,hdpi ......),还是可以通过9个补丁实现
如何处理按钮?我尝试将按钮(在Photoshop中是一个组)保存到新图像中并将其保存为PNG.当使用ImageButton加载布局并尝试使用手机时,按钮太大了.如何保证不同类型屏幕上按钮的大小?我是否需要针对不同分辨率(mdpi ...)使用不同大小的此按钮,如果是这样,我将如何知道hdpi分辨率或mdpi分辨率的此按钮大小是多少?或者也许我应该将按钮的宽度和高度强制为60dp的值,但这对我来说听起来不对.我知道我可以创建一个形状并将其应用到按钮的背景但是,Facebook按钮呢?我想,在这种情况下,我需要一个以PNG为背景的ImageButton.
设计师给了我一个背景,包括在我的应用程序中.它有很多细节,所以当试图创建一个9补丁图像时,它变得模糊.
因此,决定拥有Android设备中所有主要屏幕密度的背景,背景图像大小应该是什么?
例如:
我应该遵循哪些标准?
非常感谢,
费利佩
我的数据集有一个 datetime 列,该列在很多天的一天中的每个小时都有一个条目。例如:
123412,2020-03-26 12:00,
123412,2020-03-27 12:00,
123412,2020-03-27 09:00,
123412,2020-03-27 09:00,
123412,2020-03-27 15:00,
123412,2020-03-26 15:00,
123412,2020-03-27 11:00,
123412,2020-03-27 12:00,
Run Code Online (Sandbox Code Playgroud)
该示例没有排序,但正如我所说,一天中的每个小时都有一个条目。
我想过滤这些数据的方法是,例如,采用 datetime 2020-03-26 12:00。然后,过滤器将返回以下行:
等等。
我试过Grouper这样的,df2 = df2.groupby(pd.Grouper(key=DATETIME, freq='D'))但没有奏效。
我怎样才能做到这一点?谢谢
android ×9
background ×1
dataframe ×1
facebook ×1
modal-dialog ×1
pandas ×1
progress-bar ×1
psd ×1
python ×1
python-3.x ×1